🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

select-shell

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

select-shell

list of select for nodejs on terminal.

1.1.3
latest
Version published
Weekly downloads
1K
-8.14%
Maintainers
1
Weekly downloads
 
Created

select-shell

Item selection for commandline nodejs apps.
  • Easy to use.
  • Single / multiple item-select.
  • Optional cancel message.
  • Color/styling/spacing options.
  • Only depends on 'colors'!

select-shell example image

Installation

npm install select-shell

Usage

Simply navigate + make selection with the arrow keys...

Up and Down - Navigates on the options
Right - Check the option
Left - Uncheck the option
Enter/Return - confirms the options selected
Esc - Cancel/Exit

Code

'use strict';

var list = require('./index')(
  /* possible configs */
  {
    pointer: ' ▸ ',
    pointerColor: 'yellow',
    checked: ' ◉  ',
    unchecked:' ◎  ',
    checkedColor: 'blue',
    msgCancel: 'No selected options!',
    msgCancelColor: 'orange',
    multiSelect: true,
    inverse: true,
    prepend: true,
    disableInput: true
  }
);

var stream = process.stdin;

list.option(' One    ')
    .option(' Two    ')
    .option(' Three  ')
    .list();

list.on('select', function(options){
  console.log(options);
  process.exit(0);
});

list.on('cancel', function(options){
  console.log('Cancel list, '+ options.length +' options selected');
  process.exit(0);
});

Optional configs

var select = require('select-shell')(
  /* These are the default values */
  {
    pointer: '> ',
    pointerColor: 'white',
    checked: ' ✓',
    unchecked: '',
    checkedColor: 'green',
    msgCancel: 'No selected options!',
    msgCancelColor: 'red',
    multiSelect: true,
    inverse: false,
    prepend: false,
    disableInput: true
  }
);

And for coffee drinkers, please see sample.coffee.

list = require('.')
  pointer    : ' ► '
  checked    : ' ◉  '
  unchecked  : ' ◎  '
  prepend    : true

The scheme of color is equal to the module colors.

stylecolortheme
boldyellowrainbow
italiccyanrandom
underlinewhitezebra
inversemagenta
green
red
grey
blue

FAQs

Package last updated on 02 Aug 2019

Did you know?

Socket

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