function Command::addOption
Adds an option.
Parameters
$shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts:
$mode The option mode: One of the InputOption::VALUE_* constants:
$default The default value (must be null for InputOption::VALUE_NONE):
array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion:
Return value
$this
Throws
InvalidArgumentException If option mode is invalid or incompatible
2 methods override Command::addOption()
- LazyCommand::addOption in vendor/
symfony/ console/ Command/ LazyCommand.php - TraceableCommand::addOption in vendor/
symfony/ console/ Command/ TraceableCommand.php - Adds an option.
File
-
vendor/
symfony/ console/ Command/ Command.php, line 432
Class
- Command
- Base class for all commands.
Namespace
Symfony\Component\Console\CommandCode
public function addOption(string $name, string|array|null $shortcut = null, ?int $mode = null, string $description = '', mixed $default = null, array|\Closure $suggestedValues = []) : static {
$this->definition
->addOption(new InputOption($name, $shortcut, $mode, $description, $default, $suggestedValues));
$this->fullDefinition?->addOption(new InputOption($name, $shortcut, $mode, $description, $default, $suggestedValues));
return $this;
}