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

buildArgsFormat() public method

public buildArgsFormat ( ArgsFormat $baseFormat = null )
$baseFormat Webmozart\Console\Api\Args\Format\ArgsFormat
    public function buildArgsFormat(ArgsFormat $baseFormat = null)
    {
        $formatBuilder = ArgsFormat::build($baseFormat);
        if (!$this->isAnonymous()) {
            $flags = $this->isLongNamePreferred() ? CommandOption::PREFER_LONG_NAME : CommandOption::PREFER_SHORT_NAME;
            $formatBuilder->addCommandOption(new CommandOption($this->getName(), $this->getShortName(), $this->getAliases(), $flags));
        }
        $formatBuilder->addOptions($this->getOptions());
        $formatBuilder->addArguments($this->getArguments());
        return $formatBuilder->getFormat();
    }

Usage Example

 public function testBuildAnonymousArgsFormat()
 {
     $baseFormat = new ArgsFormat();
     $this->config->setName('command');
     $this->config->setShortName('c');
     $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));
 }