addCommandOption() публичный Метод

The existing command options stored in the builder are preserved.
См. также: addCommandOptions()
public addCommandOption ( CommandOption $commandOption ) : static
$commandOption CommandOption The command option to add.
Результат static The current instance.
Пример #1
0
 /**
  * @expectedException \Webmozart\Console\Api\Args\CannotAddOptionException
  */
 public function testFailIfAddingOptionWithSameShortNameAsCommandOptionAlias()
 {
     $this->builder->addCommandOption(new CommandOption('option1', 'o', array('a')));
     $this->builder->addOption(new Option('option2', 'a'));
 }
Пример #2
0
 /**
  * Creates a format builder for a set of arguments and options.
  *
  * @param array      $elements   The arguments and options to add to the
  *                               builder.
  * @param ArgsFormat $baseFormat The base format.
  *
  * @return ArgsFormatBuilder The created builder.
  */
 private function createBuilderForElements(array $elements, ArgsFormat $baseFormat = null)
 {
     $builder = new ArgsFormatBuilder($baseFormat);
     foreach ($elements as $element) {
         if ($element instanceof CommandName) {
             $builder->addCommandName($element);
         } elseif ($element instanceof CommandOption) {
             $builder->addCommandOption($element);
         } elseif ($element instanceof Option) {
             $builder->addOption($element);
         } elseif ($element instanceof Argument) {
             $builder->addArgument($element);
         } else {
             throw new InvalidArgumentException(sprintf('Expected instances of CommandName, CommandOption, ' . 'Option or Argument. Got: %s', is_object($element) ? get_class($element) : gettype($element)));
         }
     }
     return $builder;
 }