Symfony\Component\Console\Helper\SymfonyQuestionHelper::writePrompt PHP 메소드

writePrompt() 보호된 메소드

protected writePrompt ( Symfony\Component\Console\Output\OutputInterface $output, Symfony\Component\Console\Question\Question $question )
$output Symfony\Component\Console\Output\OutputInterface
$question Symfony\Component\Console\Question\Question
    protected function writePrompt(OutputInterface $output, Question $question)
    {
        $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
        $default = $question->getDefault();
        switch (true) {
            case null === $default:
                $text = sprintf(' <info>%s</info>:', $text);
                break;
            case $question instanceof ConfirmationQuestion:
                $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
                break;
            case $question instanceof ChoiceQuestion && $question->isMultiselect():
                $choices = $question->getChoices();
                $default = explode(',', $default);
                foreach ($default as $key => $value) {
                    $default[$key] = $choices[trim($value)];
                }
                $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
                break;
            case $question instanceof ChoiceQuestion:
                $choices = $question->getChoices();
                $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($choices[$default]));
                break;
            default:
                $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
        }
        $output->writeln($text);
        if ($question instanceof ChoiceQuestion) {
            $width = max(array_map('strlen', array_keys($question->getChoices())));
            foreach ($question->getChoices() as $key => $value) {
                $output->writeln(sprintf("  [<comment>%-{$width}s</comment>] %s", $key, $value));
            }
        }
        $output->write(' > ');
    }
SymfonyQuestionHelper