Inquirer list input
A list prompt with arbitrary text input for Inquirer
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;inquirerprompt 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 = ; inquirer;inquirerprompt type: 'list-input' name: 'from' message: 'Select a state to travel from' choices: 'AL' 'AR' { console;};
Inspired by inquirer-autocomplete-prompt