Symfony\Component\Console\Command\Command::addArgument PHP Method

addArgument() public method

Adds an argument.
public addArgument ( string $name, integer $mode = null, string $description = '', mixed $default = null ) : Command
$name string The argument name
$mode integer The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
$description string A description text
$default mixed The default value (for InputArgument::OPTIONAL mode only)
return Command The current instance
    public function addArgument($name, $mode = null, $description = '', $default = null)
    {
        $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
        return $this;
    }

Usage Example

Example #1
2
 /**
  * {@inheritdoc}
  */
 public function configure(Command $command)
 {
     $locatorsExamples = implode(PHP_EOL, array_map(function ($locator) {
         return '- ' . $locator;
     }, $this->specificationFinder->getExampleLocators()));
     $command->addArgument('paths', InputArgument::OPTIONAL, 'Optional path(s) to execute. Could be:' . PHP_EOL . $locatorsExamples)->addOption('--dry-run', null, InputOption::VALUE_NONE, 'Invokes formatters without executing the tests and hooks.');
 }
All Usage Examples Of Symfony\Component\Console\Command\Command::addArgument