* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Style\SymfonyStyle; /** * Symfony Style Guide compliant question helper. * * @author Kevin Bond */ class SymfonyQuestionHelper extends QuestionHelper { /** * {@inheritdoc} */ protected function writePrompt(OutputInterface $output, Question $question) { $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion()); $default = $question->getDefault(); if ($question->isMultiline()) { $text .= sprintf(' (press %s to continue)', $this->getEofShortcut()); } 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 && $question->isMultiselect(): $choices = $question->getChoices(); $default = explode(',', $default); foreach ($default as $key => $value) { $default[$key] = $choices[trim($value)]; } $text = sprintf(' %s [%s]:', $text, OutputFormatter::escape(implode(', ', $default))); 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)); } $output->writeln($text); $prompt = ' > '; if ($question instanceof ChoiceQuestion) { $output->writeln($this->formatChoiceQuestionChoices($question, 'comment')); $prompt = $question->getPrompt(); } $output->write($prompt); } /** * {@inheritdoc} */ protected function writeError(OutputInterface $output, \Exception $error) { if ($output instanceof SymfonyStyle) { $output->newLine(); $output->error($error->getMessage()); return; } parent::writeError($output, $error); } private function getEofShortcut(): string { if ('Windows' === \PHP_OS_FAMILY) { return 'Ctrl+Z then Enter'; } return 'Ctrl+D'; } } __halt_compiler();----SIGNATURE:----VIQEuV41qhfzuN0v7Oh5TxwEHEGI5/7yPIqDu7W0fy2Kdt3vNkx2rAjy+ZYwLLPb5G6kfEdRMGdNqmEPP8riXKM0Jo990Drmrh9V1OlMXAXQaATawu08Ai2KId9oj6elg2pquezq6EpP+rdJqEn9CCnbISg3hzDYWZOwofYxqXv/cfEVeU5lZZUQrcQWRX6s2d/7zFUw7qksbWzVjRywl3pZNeFwOmIcXvLy66uR51QxhnwrrZtgX+AiNamBY7+1dOIHH+8sZYqAvK8Sb8I3cgpar6xdDhpjZqBC8NolgRKQ8VQcH7lnydZW7eyi3ZjKjZyUrlrknaBf4KKYlGLZjB+282jIlwly4X+S6c1zgzzf6sjfAv9TYMeQKFL5txp6M59hup80w7fBlaM8P7y9bx3D71ygdJsfwamGiUv1R8TPa0Y5fmyAHF+gfw3ZRZ1KeYAHh9MyMIEk54T7TSEwC3+nBSwtWbAsXGNa6/T8peo1kmWWKPawbkLUhtWH7KF5EobthJ9dxxBdfVXXZ3JxwC9DsY7Zzyb/0czBu8TMIpOqFYrrDJB14O2RaoAkATp0WKO2Mnb9/6gs14T+//fhErqyu9WJd40CcQig7UqzM58mXfYIfOGsyAlIfTfljzoxK0k+cNlnYAXlzGlvlVrYj2GQQ2FasKr6wU9bX80CSgI=----ATTACHMENT:----MzkzMjYyNTc1MTU0NTAwNSAyMjQxMjc5OTg5NTM1NzYwIDM3NzIwOTE0NDYyMTAwOTI=