1.0.1 • Published 7 years ago

inquirer-checkbox-search v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

inquirer-checkbox-search

This is a prompt with user input search functionality made for inquirer.

Inspired by the checkbox prompt included in the inquirer core and inquirer-autocomplete-prompt.

Note: At the time of writing, this prompt has not been thoroughly vetted and tested, but currently serves the purpose it was originally written for. Contributions welcome.

Installation

npm install --save inquirer-checkbox-search

Usage

This prompt is anonymous, meaning you can register this prompt with the type name you please:

inquirer.registerPrompt('checkbox-search', require('inquirer-checkbox-search'));
inquirer.prompt({
  type: 'checkbox-search',
  ...
})

Change checkbox-search to whatever you prefer.

Options

This prompt is essentially a hybrid between inquirer checkbox and inquirer-autocomplete-prompt. See each Readme for available options, excluding suggestOnly.

Example

inquirer.registerPrompt('checkbox-search', require('inquirer-checkbox-search'))
inquirer.prompt([{
  type: 'checkbox-search',
  name: 'states',
  message: 'Which states would you like to visit?',
  source: (answersSoFar, input) => {
    return myApi.searchStates(input)
  }
}]).then(answers => {
  // etc
})

See example.js for a working example.

Keybindings

Use the up/down arrows to navigate the current list. Begin typing to filter the list results. The items selected in the filtered list persist through all searches.

Use the right arrow to make a selection. Use shift+right arrow to select all items or control+right arrow to inverse all items in either the original or filtered search list. Press enter when finished with your selection.