-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
8000 [Console] allow multiline responses to console questions #14002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,6 +234,36 @@ You can also specify if you want to not trim the answer by setting it directly w | |
$name = $helper->ask($input, $output, $question); | ||
} | ||
|
||
Accept Multiline Answers | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. versionadded:: 5.2 | ||
8000 |
|
|
The ``setMultiline()`` and ``isMultiline()`` methods were introduced in | ||
Symfony 5.2. | ||
|
||
By default, the question helper stops reading user input when it receives a newline | ||
character (i.e., when the user hits ``ENTER`` once). However, you may specify that | ||
the response to a question should allow multiline answers by passing ``true`` to | ||
:method:`Symfony\\Component\\Console\\Question\\Question::setMultiline`:: | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would just add something like: // src/Command/MyCommand.php There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what you mean. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Never mind. I see what you mean now. The context for your comment didn't show the lines below, so I thought you were talking about the lines above. 😁 None of the other examples on this page show an example name for their command script. If I add this here, should I also add it to the rest of the examples? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ho i did not figure that other have not but i do not know if you should update all others :s There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't disagree, but it's inconsistent with the rest of the examples in this file. |
||
use Symfony\Component\Console\Question\Question; | ||
|
||
// ... | ||
public function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
// ... | ||
$helper = $this->getHelper('question'); | ||
|
||
$question = new Question('How do you solve world peace?'); | ||
fabpot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$question->setMultiline(true); | ||
|
||
$answer = $helper->ask($input, $output, $question); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing a return here if i am not mistaken, or another There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied from other examples in the docs, none of which include a return or |
||
|
||
Multiline questions stop reading user input after receiving an end-of-transmission | ||
control character (``Ctrl-D`` on Unix systems or ``Ctrl-Z`` on Windows). | ||
|
||
Hiding the User's Response | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.