-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[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
[Console] allow multiline responses to console questions #14002
Conversation
Updated for changes made in symfony/symfony#37683 |
…ns (ramsey) This PR was merged into the 5.2-dev branch. Discussion ---------- [Console] allow multiline responses to console questions | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | n/a | License | MIT | Doc PR | symfony/symfony-docs#14002 By default, the question helper stops reading user input when it receives a newline character (i.e., when the user hits `ENTER` once). However, with this feature, developers may specify that the response to a question should allow multiline answers by passing `true` to `setMultiline()`. Multiline questions stop reading user input after receiving three newline characters in a row (i.e., the user hits `ENTER` three times) or an end-of-transmission control character (`Ctrl-D` on Unix systems or `Ctrl-Z` on Windows). If a user enters a newline character without input, control is returned to the question class, where the input may be validated to prompt the user again (in the case of a required question), or control may be passed along to the rest of the script. Commits ------- 0bf89cd [Console] allow multiline responses to console questions
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 comment
The 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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
ho i did not figure that other have not
but yes i see a lot on code example the path file on top as a comment
it helps understanding in which file the class is and its meaning etc :)
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 comment
The 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.
$question->setMultiline(true); | ||
|
||
$answer = $helper->ask($input, $output, $question); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 comment
The 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 // ...
at the end of the method.
Thank you for your first contribution to the Symfony documentation @ramsey. |
Documentation for new multiline responses feature proposed in symfony/symfony#37683