diff --git a/lib/private/Console/CommandAdapter.php b/lib/private/Console/CommandAdapter.php index 089c62e789557..6a3da3b64368c 100644 --- a/lib/private/Console/CommandAdapter.php +++ b/lib/private/Console/CommandAdapter.php @@ -139,7 +139,7 @@ public function configure(): void { } $default = $reflection->hasDefaultValue() ? $reflection->getDefaultValue() : null; - $this->addArgument($arg->name, $mode, $arg->description, $default); + $this->addArgument($arg->name, $mode, $arg->description, $default, $arg->suggestedValues); } foreach ($this->options as $option) { @@ -169,7 +169,7 @@ public function configure(): void { throw new \LogicException(\sprintf('The option "$%s" of "%s" must have a default value of false.', $name, $reflection->getSourceName())); } - $this->addOption($option->name, $option->shortcut, InputOption::VALUE_OPTIONAL, $option->description, $default); + $this->addOption($option->name, $option->shortcut, InputOption::VALUE_OPTIONAL, $option->description, $default, $option->suggestedValues); continue; } @@ -201,7 +201,7 @@ public function configure(): void { $mode = InputOption::VALUE_REQUIRED; } - $this->addOption($option->name, $option->shortcut, $mode, $option->description, $default); + $this->addOption($option->name, $option->shortcut, $mode, $option->description, $default, $option->suggestedValues); } } diff --git a/lib/public/Console/Attribute/Argument.php b/lib/public/Console/Attribute/Argument.php index f7f590d5f5996..9da6fd9a2e65e 100644 --- a/lib/public/Console/Attribute/Argument.php +++ b/lib/public/Console/Attribute/Argument.php @@ -63,11 +63,13 @@ final class Argument { * * @param string $description The description of the argument, displayed with the help page * @param string $name The name of the argument + * @param array|\Closure $suggestedValues An array or a closure that provides suggested values for the argument. * @since 35.0.0 */ public function __construct( public string $description = '', public string $name = '', + public array|\Closure $suggestedValues = [], ) { } } diff --git a/lib/public/Console/Attribute/Option.php b/lib/public/Console/Attribute/Option.php index baf152d7ed388..eae0d95b528fd 100644 --- a/lib/public/Console/Attribute/Option.php +++ b/lib/public/Console/Attribute/Option.php @@ -69,12 +69,14 @@ final class Option { * @param string $description The description of the option, displayed with the help page * @param string $name The name of the option * @param array|string|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts + * @param array|\Closure $suggestedValues An array or a closure that provides suggested values for the option. * @since 35.0.0 */ public function __construct( public string $description = '', public string $name = '', public array|string|null $shortcut = null, + public array|\Closure $suggestedValues = [], ) { } }