-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Enhancement/discussion: change in flow based on answers. #45
Comments
Hi, Inquirer prompt offer such a possibility through the For example: inquirer.prompt([{
name: "food",
type: "list",
message: "What do you want",
choices: [ "Calzone", "Pizza", "Sub" ]
}, {
name: "toppings",
type: "list",
when: function( answers ) {
// Only run if user answered Pizza to the first prompt
return answers.food === "Pizza";
},
// etc
}]); Does it work for your use case? |
Choosing Calzone (or Pizza or Sub) returns exception generated from base.js:83 So based on that no. For the use case as far as I see it, you want to be able to dog leg to another set of questions (like asking what you want on your calzone) then go back to asking any further questions. So really what is needed (thinking out loud) is a way to diverge to another question set and come back. Also you need to be able to specify those other questions in a reasonably easy to maintain manner. You have the "when" but what about the "then", is what I guess I'm saying. |
That's because I haven't feed every required field in my example (so I put I see what you mean, but this is 100% possible with the current Try it out with |
I think this should be in the documentation. I've also found a separate issue opened for this purpose #1081 |
As pizza.js shows things work fine as long as question flow is in a strictly linear fashion. But consider where the answer to one question affects the flow of another question. For example lets say that Node Pizza also offers calzones and subs and salads. Then a user would need to be asked what type of thing they want to order and based on that they would have a subset of questions to answer (perhaps coming back to the original series of questions to finish up/continue).
Could that be handled with some alterations to the inquirier module without adversely affecting the linear/serial flow of questions?
The text was updated successfully, but these errors were encountered: