getQuestion()); $text = $this->ensureEndsWithPunctuation($text); $text = " $text"; $default = $question->getDefault(); if ($question->isMultiline()) { $text .= sprintf(' (press %s to continue)', 'Windows' == PHP_OS_FAMILY ? 'Ctrl+Z then Enter' : 'Ctrl+D'); } switch (true) { case null === $default: $text = sprintf('%s', $text); break; case $question instanceof ConfirmationQuestion: $text = sprintf('%s (yes/no) [%s]', $text, $default ? 'yes' : 'no'); break; case $question instanceof ChoiceQuestion: $choices = $question->getChoices(); $text = sprintf('%s [%s]', $text, OutputFormatter::escape($choices[$default] ?? $default)); break; default: $text = sprintf('%s [%s]', $text, OutputFormatter::escape($default)); break; } $output->writeln($text); if ($question instanceof ChoiceQuestion) { foreach ($question->getChoices() as $key => $value) { with(new TwoColumnDetail($output))->render($value, $key); } } $output->write('❯ '); } /** * Ensures the given string ends with punctuation. * * @param string $string * @return string */ protected function ensureEndsWithPunctuation($string) { if (! str($string)->endsWith(['?', ':', '!', '.'])) { return "$string:"; } return $string; } }