https://github.com/faressoft/inquirer-checkbox-plus-prompt
Checkbox with autocomplete and other additions for Inquirer
https://github.com/faressoft/inquirer-checkbox-plus-prompt
checkbox cli command-line fuzzy-search inquirer javascript nodejs prompt
Last synced: 2 months ago
JSON representation
Checkbox with autocomplete and other additions for Inquirer
- Host: GitHub
- URL: https://github.com/faressoft/inquirer-checkbox-plus-prompt
- Owner: faressoft
- License: mit
- Created: 2018-03-08T20:55:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-17T16:35:03.000Z (over 1 year ago)
- Last Synced: 2024-04-29T19:40:38.081Z (about 1 year ago)
- Topics: checkbox, cli, command-line, fuzzy-search, inquirer, javascript, nodejs, prompt
- Language: JavaScript
- Size: 294 KB
- Stars: 37
- Watchers: 3
- Forks: 24
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Inquirer Checkbox Plus Prompt
A plugin for [Inquirer](https://github.com/SBoudrias/Inquirer.js), similar to the original checkbox with extra features.
[](https://www.npmjs.com/package/inquirer-checkbox-plus-prompt)
[](https://github.com/faressoft/inquirer-checkbox-plus-prompt/blob/master/LICENSE)
![]()
The animated GIF is made by Terminalizer# Installation
```
npm install inquirer-checkbox-plus-prompt
```# Usage
You can name it with any name other than `checkbox-plus`, just change the string `'checkbox-plus'` to anything else.
```js
inquirer.registerPrompt('checkbox-plus', require('inquirer-checkbox-plus-prompt'));inquirer.prompt({
type: 'checkbox-plus',
...
})
```# Options
Takes `type`, `name`, `message`, `source`[, `filter`, `validate`, `default`, `pageSize`, `highlight`, `searchable`] properties.
The extra options that this plugin provides are:
* **source**: (Function) a method that called to return a promise that should be resolved with a list of choices in a similar format as the `choices` option in the original `checkbox` prompt of `Inquirer`.
* **highlight**: (Boolean) if `true`, the current selected choice gets highlighted. Default: `false`.
* **searchable**: (Boolean) if `true`, allow the user to filter the list. The `source` function gets called everytime the search query is changed. Default: `false`.# Example
Check [example.js](/example.js?raw=true) for a more advanced example.
```js
var inquirer = require('inquirer');
var fuzzy = require('fuzzy');inquirer.registerPrompt('checkbox-plus', require('./index'));
var colors = ['red', 'green', 'blue', 'yellow'];
inquirer.prompt([{
type: 'checkbox-plus',
name: 'colors',
message: 'Enter colors',
pageSize: 10,
highlight: true,
searchable: true,
default: ['yellow', 'red'],
source: function(answersSoFar, input) {input = input || '';
return new Promise(function(resolve) {
var fuzzyResult = fuzzy.filter(input, colors);
var data = fuzzyResult.map(function(element) {
return element.original;
});resolve(data);
});}
}]).then(function(answers) {console.log(answers.colors);
});
```# License
This project is under the MIT license.