Socket
Socket
Sign inDemoInstall

inquirer-checkbox-plus-prompt

Package Overview
Dependencies
52
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    inquirer-checkbox-plus-prompt

Checkbox with autocomplete and other additions for Inquirer


Version published
Weekly downloads
672K
decreased by-15.88%
Maintainers
1
Install size
6.74 MB
Created
Weekly downloads
 

Readme

Source

Inquirer Checkbox Plus Prompt

A plugin for Inquirer, similar to the original checkbox with extra features.

npm npm


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.

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 for a more advanced example.

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.

Keywords

FAQs

Last updated on 23 Jan 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc