Inquirer.js icon indicating copy to clipboard operation
Inquirer.js copied to clipboard

Additionnal infos parameter

Open antoine-pous opened this issue 8 years ago • 1 comments

Hi!

Sometime we need to give more informations about the user choices and the problem is when we wrote all the questions into the same object.

let questions = [
  {
    // question 1
  },
  {
    // question 2
  }
]

inquirer.prompt(questions).then(function(answers) {
  // Do the stuff
})

This approach allow me to build a wrapper for the questions and a validator for all submitted answers. This work perfectly but i can't give additionnal information when it's required.

Can you add a param to provide a string wich can be colored with chalk? Like:

tooltip: chalk.yellow('[Warning] Using this option without granted access can make you banned!')

Allow a callback could be really usefull too

Thank you !

antoine-pous avatar May 25 '17 09:05 antoine-pous

You can use the when function to console.log() warning on your own. Or you can just split your prompts in multiples functions that you chain:

prompt1()
    .then(prompt2)
    .then(prompt3)
    .then(onAnswer);

I don't think Inquirer needs to provide a specific API for that.

SBoudrias avatar Jun 18 '17 06:06 SBoudrias

[cleaning up old issues]

Prompts taking a list of choices now exposes a description option. That description test appears when a choice is highlighted. And with theme the display can be customized.

SBoudrias avatar Sep 28 '24 21:09 SBoudrias