@@ -319,6 +319,12 @@ public function run(InputInterface $input, OutputInterface $output): int
319319 */
320320public function complete (CompletionInput $ input ,CompletionSuggestions $ suggestions ):void
321321 {
322+ $ definition =$ this ->getDefinition ();
323+ if (CompletionInput::TYPE_OPTION_VALUE ===$ input ->getCompletionType () &&$ definition ->hasOption ($ input ->getCompletionName ())) {
324+ $ suggestions ->suggestValues ($ definition ->getOption ($ input ->getCompletionName ())->getSuggestedValues ($ input ));
325+ }elseif (CompletionInput::TYPE_ARGUMENT_VALUE ===$ input ->getCompletionType () &&$ definition ->hasArgument ($ input ->getCompletionName ())) {
326+ $ suggestions ->suggestValues ($ definition ->getArgument ($ input ->getCompletionName ())->getSuggestedValues ($ input ));
327+ }
322328 }
323329
324330/**
@@ -427,17 +433,22 @@ public function getNativeDefinition(): InputDefinition
427433/**
428434 * Adds an argument.
429435 *
430- * @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
431- * @param mixed $default The default value (for InputArgument::OPTIONAL mode only)
436+ * @param $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
437+ * @param $default The default value (for InputArgument::OPTIONAL mode only)
438+ * @param array|\Closure(CompletionInput):array $suggestedValues The values used for input completion
432439 *
433440 * @throws InvalidArgumentException When argument mode is not valid
434441 *
435442 * @return $this
436443 */
437- public function addArgument (string $ name ,int $ mode =null ,string $ description ='' ,mixed $ default =null ):static
444+ public function addArgument (string $ name ,int $ mode =null ,string $ description ='' ,mixed $ default =null , /*array|\Closure $suggestedValues = null*/ ):static
438445 {
439- $ this ->definition ->addArgument (new InputArgument ($ name ,$ mode ,$ description ,$ default ));
440- $ this ->fullDefinition ?->addArgument(new InputArgument ($ name ,$ mode ,$ description ,$ default ));
446+ $ suggestedValues =5 <=\func_num_args () ?func_get_arg (4 ) : [];
447+ if (!\is_array ($ suggestedValues ) && !$ suggestedValuesinstanceof \Closure) {
448+ throw new \TypeError (sprintf ('Argument 5 passed to "%s()" must be array or \Closure, "%s" given. ' ,__METHOD__ ,get_debug_type ($ suggestedValues )));
449+ }
450+ $ this ->definition ->addArgument (new InputArgument ($ name ,$ mode ,$ description ,$ default ,$ suggestedValues ));
451+ $ this ->fullDefinition ?->addArgument(new InputArgument ($ name ,$ mode ,$ description ,$ default ,$ suggestedValues ));
441452
442453return $ this ;
443454 }
@@ -448,15 +459,20 @@ public function addArgument(string $name, int $mode = null, string $description
448459 * @param $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
449460 * @param $mode The option mode: One of the InputOption::VALUE_* constants
450461 * @param $default The default value (must be null for InputOption::VALUE_NONE)
462+ * @param array|\Closure(CompletionInput):array $suggestedValues The values used for input completion
451463 *
452464 * @throws InvalidArgumentException If option mode is invalid or incompatible
453465 *
454466 * @return $this
455467 */
456- public function addOption (string $ name ,string |array $ shortcut =null ,int $ mode =null ,string $ description ='' ,mixed $ default =null ):static
468+ public function addOption (string $ name ,string |array $ shortcut =null ,int $ mode =null ,string $ description ='' ,mixed $ default =null , /*array|\Closure $suggestedValues = []*/ ):static
457469 {
458- $ this ->definition ->addOption (new InputOption ($ name ,$ shortcut ,$ mode ,$ description ,$ default ));
459- $ this ->fullDefinition ?->addOption(new InputOption ($ name ,$ shortcut ,$ mode ,$ description ,$ default ));
470+ $ suggestedValues =6 <=\func_num_args () ?func_get_arg (5 ) : [];
471+ if (!\is_array ($ suggestedValues ) && !$ suggestedValuesinstanceof \Closure) {
472+ throw new \TypeError (sprintf ('Argument 5 passed to "%s()" must be array or \Closure, "%s" given. ' ,__METHOD__ ,get_debug_type ($ suggestedValues )));
473+ }
474+ $ this ->definition ->addOption (new InputOption ($ name ,$ shortcut ,$ mode ,$ description ,$ default ,$ suggestedValues ));
475+ $ this ->fullDefinition ?->addOption(new InputOption ($ name ,$ shortcut ,$ mode ,$ description ,$ default ,$ suggestedValues ));
460476
461477return $ this ;
462478 }