-
-
Couldn't load subscription status.
- Fork 1.3k
Open
Labels
Description
The case
A wish to display questions (for reference) which are not asked through when property.
The problem
when property just hides the question when its value is false.
Potential solution
- A new property, or
- an extra parameter to
whenproperty function
which will declare if a not-asked (not-activated) question should be displayed or not.
Example
import inquirer from "inquirer";
inquirer
.prompt([
{
type: 'confirm',
name: 'fruit',
message: 'Is it a fruit?',
default: true
},
{
type: 'confirm',
name: 'sweet',
message: 'Is it sweet?',
default: true,
when: function (answers, status) {
status.activated = answers.fruit ? false : true;
status.displayed = true;
return status;
},
},
{
type: 'confirm',
name: 'example',
message: 'Is it a good example?',
default: true,
}
])
.then(() => {
...
})? Is it a fruit? Yes
? Is it sweet? Yes (# default value and, for example, in very light colour to imply that it's not activated)
? is it a good example? Y/n
...
Tia