select-line prompt for inquirer
npm install --save inquirer-select-line
inquirer.registerPrompt('selectLine', require('inquirer-select-line'));
inquirer.prompt({
type: 'selectLine',
message: message,
name: name,
choices: choices,
placeholder: placeholder,
})
Change selectLine
to whatever you might prefer.
-message : (String|Function) The question to print. If defined as a function, the first parameter will be the current inquirer session answers.
-name : (String) The name to use when storing the answer in the answers hash. If the name contains periods, it will define a path in the answers hash.
-choices: (Array|Function) Choices array or a function returning a choices array. If defined as a function, the first parameter will be the current inquirer session answers. Array values have to be simple strings. The choices array can also contain a Separator.
-placeholder (String|Function) The name to display as a placeholder for chosen line. If defined as a function, the first parameter will be index of currently chosen answer. (optional) default: INSERT HERE
.
inquirer.registerPrompt('selectLine', require('inquirer-selectLine'));
inquirer.prompt([{
type: 'selectLine',
message: 'Where add line?',
name: 'line',
choices: ['first', 'second', 'third', 'fourth'],
}]).then(function(answers) {
console.log('Chosen line: ' answers.line);
/*
OUTPUT :
Chosen line: 2
*/
});
MIT