Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

This package has been deprecated

Author message:

Use the MultiSelect prompt from the enquirer package.

multiselect-prompt

0.3.2 • Public • Published

multiselect-prompt

Deprecated. Use the MultiSelect prompt from enquirer.


A prompt to select zero or more items.

asciicast

npm version dependency status dev dependency status ISC-licensed chat on gitter

multiselect-prompt uses cli-styles and prompt-skeleton to have a look & feel consistent with other prompts.

Installing

npm install multiselect-prompt

Usage

const prompt = require('multiselect-prompt')
 
const colors = [
    {title: 'red',    value: '#f00'},
    {title: 'yellow', value: '#ff0'},
    {title: 'green',  value: '#0f0'},
    {title: 'blue',   value: '#00f', selected: true},
    {title: 'black',  value: '#000'},
    {title: 'white',  value: '#fff'}
]
 
const selected = (items) => items
    .filter((item) => item.selected)
    .map((item) => item.value)
 
// All these options are optional
const opts = {
    cursor: 1,     // Initial position of the cursor, defaults to 0 (first entry)
    maxChoices: 3, // Maximum number of selectable options (defaults to Infinity)
    // The message to display as hint if enabled, below is the default value
    hint: '– Space to select. Return to submit.'
}
 
prompt('Which colors do you like?', colors, opts)
.on('data', (data) => console.log('Changed to', selected(data.value)))
.on('abort', (items) => console.log('Aborted with', selected(items)))
.on('submit', (items) => console.log('Submitted with', selected(items)))

Related

Contributing

If you have a question, found a bug or want to propose a feature, have a look at the issues page.

Install

npm i multiselect-prompt

DownloadsWeekly Downloads

342

Version

0.3.2

License

ISC

Unpacked Size

7.51 kB

Total Files

4

Last publish

Collaborators

  • avatar