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] Add a RepeatedQuestion #19678
Comments
Looks like a valid case to me |
BTW it could also be used for things like multiline answer. Maybe we should choose a name showing this use case as well ? |
This can easily be implemented in user land with |
@jameshalsall how would you do that ? That's not that easy and would probably need some hacks. |
Depending on there relationship this is not as easy as it seems, in https://github.com/rollerworks/SkeletonDancer I started with a collection of questions, but then I wanted to add support for conditional questions (only ask when x) and then it become complicated. So Instead of adding all to a collection, each question is asked by a Questioner that keeps track of all questions, but instead of using the Symfony Console Question directly it uses a wrapper that creates the Question at a later state so that the default can be passed https://github.com/rollerworks/SkeletonDancer/blob/master/src/Question.php |
@Ener-Getick at a simple level off the top of my head... $answers = [];
$question = new Question('What is foo?', 'bar');
do {
$answers[] = $questionHelper->ask($input, $output, $question);
} while ($answer !== 'bar');
$output->writeln('You answered with ' , implode(', ', $answers); @sstok it may well get more complicated if you want to only ask Y when X has a certain answer, but that's more like a Questionnaire component, which may well have some value |
@jameshalsall yes but as i said that's very verbose. |
it's no more verbose than your suggested implementation, imo |
@jameshalsall the console output is verbose, not the call to |
@jameshalsall Good point, that's actually something I want to do in the long run :) but that will take some time. |
I'm 👎 for this proposed feature:
|
@javiereguiluz i want to use this in my QuickInstallBundle to reconfigure an app. BTW I think it would also be useful for multiline input (mails, comments, ...). |
Closing it because the related issue (#19699) was closed as "won't fix". |
Actually when I want to ask several times the same question with
SymfonyStyle
i have a very verbose output:I propose to introduce a
RepeatedQuestion
. It could be implemented like that:It would be used like that:
And the command output would be:
WDYT?
The text was updated successfully, but these errors were encountered: