Anonymous commands cannot be called by name:
php
protected function configure()
{
$this
->beginCommand('add')
->markAnonymous()
->addArgument('host', Argument::REQUIRED)
->end()
...
;
}
The name "add" is given to the command only to access the command later
on. Since the command is anonymous, the name cannot be passed when
when calling the command:
php
$ ./console add localhost
Instead, the command should be called without name:
php
$ ./console localhost
public markAnonymous ( ) : static | ||
return | static | The current instance. |
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)); }
public function testHasNoNamedCommands() { $config = new CommandConfig('command'); $config->markAnonymous(); $this->config->addCommandConfig($config); $application = new ConsoleApplication($this->config); $this->assertFalse($application->hasNamedCommands()); }