JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 299
  • Score
    100M100P100Q79694F
  • License ISC

Option selector for interactive shell application

Package Exports

  • node-option

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-option) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-option

An item selection module for interactive shell applications.

Installation

npm install node-option

API

add(text, value)

Adds the options that you want to select.

If no value is given, the given text will be a value.

render()

Displays a options on the shell and allows the user to select.

Usage

const Selector = require('./index');

const selector = new Selector({
  bracketColor: 'blue',
  markColor: 'white',
  textColor: 'yellowBright',
  highlight: true,
});

const result = selector
                .add('One')
                .add('Two')
                .add('Three')
                .add('Four')
                .render();

result.then((value) => {
  console.log(value);
}, (error) => {
  console.log(error);
});

Configuration

{
    cursor: '>',            // character of pointer
    checked: '✓',           // character to mark selected item
    unchecked: ' ',         // character to mark unselected item
    cursorColor: 'cyan',    // color of cursor
    bracketColor: 'white',  // color of bracket
    markColor: 'green',     // color of checked mark
    textColor: 'yellow',    // color of text
    multiselect: true,      // whether to select multiple items.
    highlight: true,        // Whether to highlight item that cursor points.
}
`