Skip to content

Feature request: Option to display not-asked (not-activated) questions #1076

@GHNewbiee

Description

@GHNewbiee

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 when property 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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions