Webmozart\Console\Api\Config\CommandConfig::buildArgsFormat PHP Method

buildArgsFormat() public method

Builds an {@link ArgsFormat} instance with the given base format.
public buildArgsFormat ( ArgsFormat $baseFormat = null ) : ArgsFormat
$baseFormat Webmozart\Console\Api\Args\Format\ArgsFormat The base format.
return Webmozart\Console\Api\Args\Format\ArgsFormat The built format for the console arguments.
    public function buildArgsFormat(ArgsFormat $baseFormat = null)
    {
        $formatBuilder = ArgsFormat::build($baseFormat);
        if (!$this->anonymous) {
            $formatBuilder->addCommandName(new CommandName($this->name, $this->aliases));
        }
        $formatBuilder->addOptions($this->getOptions());
        $formatBuilder->addArguments($this->getArguments());
        return $formatBuilder->getFormat();
    }

Usage Example

示例#1
0
 public function testBuildAnonymousArgsFormat()
 {
     $baseFormat = new ArgsFormat();
     $this->config->setName('command');
     $this->config->setAliases(array('alias1', 'alias2'));
     $this->config->addOption('option');
     $this->config->addArgument('argument');
     $this->config->markAnonymous();
     $expected = ArgsFormat::build($baseFormat)->addArgument(new Argument('argument'))->addOption(new Option('option'))->getFormat();
     $this->assertEquals($expected, $this->config->buildArgsFormat($baseFormat));
 }
All Usage Examples Of Webmozart\Console\Api\Config\CommandConfig::buildArgsFormat