Inquirer list input
A list prompt with arbitrary text input for Inquirer
![npm version](https://badge.fury.io/js/inquirer-list-input.png?style=flat)
This prompt style gives you a list but also allows arbitrary user input. This could allow for slight editing of list items such as when selecting file paths and you want further sub-directories.
Install
npm save --install inquirer-list-input
Usage
You can register this prompt with a name of your choosing. Here is how you would register it as 'list-input'
:
inquirer.registerPrompt('list-input', require('inquirer-list-input'));
inquirer.prompt({
type: 'list-input',
// ...
})
Options
Note: allowed options written inside square brackets ([]
) are optional. Others are required.
type
, name
, message
, editableList
[, filter
, validate
, when
]
See inquirer readme for meaning of all except source.
editableList is a Boolean, defaulting to false
. If true
, the cursor will always appear, giving the user a greater visual cue to edit list items.
Example
See example.js for a working example. Use the left and right arrows to edit a list item or ctrl a and ctrl e to jump to the beginning or end of a line.
var inquirer = require('inquirer');
inquirer.registerPrompt('list-input', require('./index'));
inquirer.prompt([{
type: 'list-input',
name: 'from',
message: 'Select a state to travel from',
choices: ['AL', 'AR']
}], function(answers) {
console.log(JSON.stringify(answers, null, 2));
});
Inspired by inquirer-autocomplete-prompt