diff --git a/src/Console/src/Traits/HelpersTrait.php b/src/Console/src/Traits/HelpersTrait.php index a711dcbc8..01eff901b 100644 --- a/src/Console/src/Traits/HelpersTrait.php +++ b/src/Console/src/Traits/HelpersTrait.php @@ -8,6 +8,7 @@ use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Style\SymfonyStyle; @@ -85,6 +86,23 @@ protected function ask(string $question, string $default = null): mixed return $this->output->ask($question, $default); } + /** + * Asks a multiple choice question. + */ + protected function choiceQuestion( + string $question, + array $choices, + mixed $default = null, + int $attempts = null, + bool $multiselect = false + ): mixed { + $question = new ChoiceQuestion($question, $choices, $default); + + $question->setMaxAttempts($attempts)->setMultiselect($multiselect); + + return $this->output->askQuestion($question); + } + /** * Prompt the user for input but hide the answer from the console. */