Skip to content
View Emmanuelking1's full-sized avatar

Block or report Emmanuelking1

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
Emmanuelking1/README.md

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('select-shell')(
  /* 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.

style color theme
bold yellow rainbow
italic cyan random
underline white zebra
inverse magenta
green
red
grey
blue

Popular repositories Loading

  1. Emmanuelking1 Emmanuelking1 Public

    Config files for my GitHub profile.

    JavaScript

  2. web3 web3 Public

  3. defi defi Public

  4. nfts nfts Public

  5. tea tea Public

  6. -gamfi-react-scripts -gamfi-react-scripts Public