beginOptionCommand() public method

An option command is executed if the corresponding option is passed after the command name. For example, if the command "server" has an option command named "--add" with the short name "-a", that command can be called with: $ console server --add ... $ console server -a ... The configuration of the option command is returned by this method. You can use the fluent interface to configure the option command before jumping back to this configuration with {@link SubCommandConfig::end()}: php protected function configure() { $this ->beginCommand('server') ->setDescription('List and manage servers') ->beginOptionCommand('add', 'a') ->setDescription('Add a server') ->addArgument('host', Argument::REQUIRED) ->addOption('port', 'p', Option::VALUE_OPTIONAL, null, 80) ->end() ->end() ... ; }
See also: editOptionCommand()
public beginOptionCommand ( string $name, string $shortName = null ) : OptionCommandConfig
$name string The name of the option command.
$shortName string The short name of the option command.
return OptionCommandConfig The option command configuration.
示例#1
0
 public function testBeginOptionCommand()
 {
     $this->config->beginOptionCommand('command1', 'a')->end()->beginOptionCommand('command2', 'b')->end();
     $this->assertEquals(array(new OptionCommandConfig('command1', 'a', $this->config, $this->applicationConfig), new OptionCommandConfig('command2', 'b', $this->config, $this->applicationConfig)), $this->config->getSubCommandConfigs());
 }