|
2 | 2 |
|
3 | 3 | namespace App\Console; |
4 | 4 |
|
5 | | -use App\Model\Repository\RuntimeEnvironments; |
6 | | -use App\Model\Repository\Pipelines; |
7 | | -use App\Model\Repository\UploadedFiles; |
8 | | -use App\Model\Entity\RuntimeEnvironment; |
9 | | -use App\Model\Entity\Pipeline; |
10 | | -use App\Model\Entity\SupplementaryExerciseFile; |
11 | | -use App\Helpers\TmpFilesHelper; |
12 | | -use App\Helpers\FileStorageManager; |
13 | | -use App\Helpers\FileStorage\ZipFileStorage; |
14 | | -use App\Helpers\ExerciseConfig\Loader; |
15 | | -use App\Helpers\ExerciseConfig\Validator as ConfigValidator; |
16 | 5 | use DateTime; |
17 | 6 | use Exception; |
18 | 7 | use RuntimeException; |
19 | 8 | use Symfony\Component\Console\Command\Command; |
20 | | -use Symfony\Component\Console\Input\InputArgument; |
21 | | -use Symfony\Component\Console\Input\InputOption; |
22 | 9 | use Symfony\Component\Console\Input\InputInterface; |
23 | 10 | use Symfony\Component\Console\Output\OutputInterface; |
24 | 11 | use Symfony\Component\Console\Question\ConfirmationQuestion; |
25 | 12 | use Symfony\Component\Console\Question\ChoiceQuestion; |
| 13 | +use Symfony\Component\Console\Question\Question; |
26 | 14 | use Symfony\Component\Console\Helper\QuestionHelper; |
27 | 15 |
|
28 | 16 | /** |
@@ -138,4 +126,23 @@ protected function select(string $text, array $options, ?callable $renderer = nu |
138 | 126 | $selectedKey = $helper->ask($this->input, $this->output, $question); |
139 | 127 | return array_key_exists($selectedKey, $translateBack) ? $translateBack[$selectedKey] : null; |
140 | 128 | } |
| 129 | + |
| 130 | + /** |
| 131 | + * Prompts the user for inputting specific text value. |
| 132 | + * @param string $text question asked to the user before prompt |
| 133 | + * @param string $default default value returned if the user does not input anything |
| 134 | + * @param bool $hidden input (e.g., when password is prompted) |
| 135 | + * @return string input (answer) from the user |
| 136 | + */ |
| 137 | + protected function prompt(string $text, string $default = '', bool $hidden = false): string |
| 138 | + { |
| 139 | + /** @var QuestionHelper */ |
| 140 | + $helper = $this->getHelper('question'); |
| 141 | + $question = new Question($text, $default); |
| 142 | + if ($hidden) { |
| 143 | + $question->setHidden(true); |
| 144 | + $question->setHiddenFallback(false); |
| 145 | + } |
| 146 | + return $helper->ask($this->input, $this->output, $question); |
| 147 | + } |
141 | 148 | } |
0 commit comments