Make database name question more specific

This commit is contained in:
Tim
2024-09-24 00:19:45 +02:00
parent 1aad1a59e4
commit 153f04ccd7
8 changed files with 40 additions and 7 deletions

View File

@ -0,0 +1,22 @@
<?php
namespace App\Service\Traits;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
trait SelectUserQuestion
{
private function getUserName(InputInterface $input, OutputInterface $output): string
{
$question = $this->getHelper('question');
if (!$name = $input->getArgument('name')) {
$selectQuestion = new ChoiceQuestion('Database name: ', $this->db->listDatabases());
$name = $question->ask($input, $output, $selectQuestion);
}
return $name;
}
}