List-style prompt. Can be used as a standalone prompt, or with a prompt system like Enquirer.
Install with npm:
$ npm install --save prompt-list
var List = require('prompt-list');
var list = new List({
type: 'list',
name: 'order',
message: 'What would you like to order?',
choices: [
'Coke',
'Diet Coke',
'Cherry Coke',
{
name: 'Sprite',
disabled: 'Temporarily unavailable'
},
'Water'
]
});
// promise
list.run()
.then(function(answer) {
console.log(answer);
});
// or async
list.ask(function(answer) {
console.log(answer);
});
var Enquirer = require('enquirer');
var enquirer = new Enquirer();
enquirer.register('list', require('prompt-list'));
var questions = [
{
type: 'list',
name: 'order',
message: 'What would you like to order?',
choices: [
'Coke',
'Diet Coke',
'Cherry Coke',
{
name: 'Sprite',
disabled: 'Temporarily unavailable'
},
'Water'
]
}
];
enquirer.ask(questions)
.then(function(answers) {
console.log(answers);
})
.catch(function(err) {
console.log(err);
});
Based on the list
prompt in inquirer.
- enquirer-prompt: Base prompt module used for creating custom prompt types for Enquirer. | homepage
- enquirer-question: Question object, used by Enquirer and prompt plugins. | homepage
- enquirer: Intuitive, plugin-based prompt system for node.js. Much faster and lighter alternative to Inquirer, with all… more | homepage
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Install dev dependencies:
$ npm install -d && npm test
Jon Schlinkert
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb-generate-readme, v0.1.31, on September 21, 2016.