Gathering detailed insights and metrics for cli-select
Gathering detailed insights and metrics for cli-select
Gathering detailed insights and metrics for cli-select
Gathering detailed insights and metrics for cli-select
@inquirer/select
Inquirer select/list prompt
select-version-cli
A simple cli to help you select release version
ember-cli-mdc-select
ember-cli addon for @material/select.
@stoked-cenv/cli-select
Simple and interactive solution to provide a list of selectable items on the command line
▶️ Simple and interactive solution to provide a list of selectable items on the command line.
npm install cli-select
Typescript
Module System
Node Version
NPM Version
94.7
Supply Chain
99
Quality
75.3
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
5,447,474
Last Day
740
Last Week
25,625
Last Month
84,135
Last Year
1,081,412
MIT License
58 Stars
23 Commits
16 Forks
3 Watchers
2 Branches
4 Contributors
Updated on Apr 22, 2025
Minified
Minified + Gzipped
Latest Version
1.1.2
Package Id
cli-select@1.1.2
Size
6.19 kB
NPM Version
6.13.4
Node Version
12.16.1
Published on
Feb 22, 2020
Cumulative downloads
Total Downloads
Last Day
-14.3%
740
Compared to previous day
Last Week
0.1%
25,625
Compared to previous week
Last Month
15%
84,135
Compared to previous month
Last Year
-38.8%
1,081,412
Compared to previous year
1
Simple and interactive solution to provide a list of selectable items on the command line.
Note: cli-select does not produce colored output by default to keep the dependencies at a minimum. See the examples below on how to reproduce this preview.
npm install --save cli-select
1const cliSelect = require('cli-select'); 2 3cliSelect(options, callback);
See the configuration section for all available options.
The select list gets immediately rendered when the function gets called and the user can then select an option with the up
and down
arrow keys. To confirm the selection, just press enter
/return
. It is also possible to cancel a selection with ctrl+c
or esc
but it is up to you how you want to handle the cancellation of a selection, the process won't be ended by default.
cli-select supports both, a callback function or a Promise (if your node environment supports promises).
If the callback function is defined, two parameters will get passed where valueId
is the numeric index if values is an array or the object key if values is an object. Both parameters will be null
if the selection gets cancelled.
1cliSelect(options, (valueId, value) => { 2 if (valueId !== null) { 3 console.log('selected ' + valueId + ': ' + value); 4 } else { 5 console.log('cancelled'); 6 } 7});
If no callback function is defined, a Promise will be returned:
1cliSelect(options).then((response) => { 2 console.log('selected ' + response.id + ': ' + response.value); 3}).catch(() => { 4 console.log('cancelled'); 5});
Note: All options are optional except
values
and will default as specified below.
The configuration gets passed to the cliSelect
function as a normal object and can contain the following keys:
1cliSelect({ 2 /** 3 * All values which can be selected. 4 * This can either be an array or an object with string keys and values. 5 * If an array is specified, the numerical index gets passed to the callback, 6 * if an object is specified, the object key will get passed to the callback. 7 * If you use the `valueRenderer` option, you can also pass in any array/object you want, 8 * the value can be anything as the `valueRenderer` returns the string to render on the terminal. 9 * 10 * @type {array|object} 11 */ 12 values: [], 13 14 /** 15 * The default value which will be pre-selected when the list shows up. 16 * If `values` is an object, the object key can be specified, otherwise 17 * it requires the numerical index in the array. 18 * 19 * @type {number|string} 20 */ 21 defaultValue: 0, 22 23 /** 24 * Symbol which gets rendered if an option is selected. 25 * 26 * @type {string} 27 */ 28 selected: '(x)', 29 30 /** 31 * Symbol which gets rendered if an option is not selected. 32 * 33 * @type {string} 34 */ 35 unselected: '( )', 36 37 /** 38 * If you want an indent before the symbol and options, 39 * you can specify it here with the number of spaces. 40 * 41 * @type {number} 42 */ 43 indentation: 0, 44 45 /** 46 * If true, the list will get removed from the output 47 * once an item gets selected or it gets cancelled. 48 * 49 * @type {boolean} 50 */ 51 cleanup: true, 52 53 /** 54 * If you use a custom object for values or want to render the values differently, 55 * you can overwrite it with a custom function. 56 * The function gets two parameters passed, the value 57 * (which can be a string or your custom object, depending what you have in the `values` option) 58 * and a boolean specifying if the value is selected. 59 * See the examples below for a simple example. 60 * 61 * @type {function} 62 */ 63 valueRenderer: (value, selected) => value, 64 65 /** 66 * Stream where the output should be written to. 67 * 68 * @type {Stream} 69 */ 70 outputStream: process.stdout, 71 72 /** 73 * Stream to use for the keyboard events. 74 * 75 * @type {Stream} 76 */ 77 inputStream: process.stdin, 78});
cli-select
does not produce colored outputs by default so you can use the package for that which you already have in your project and you don't have two packages doing basically the same at the end.
If you don't have such a package already in your project and you want the output to look similar to the preview gif above,
I recommend the packages chalk for colored output and
figures for unicode symbols with fallbacks.
These two packages are also used in the examples below but cli-select
is also compatible with every other package.
1const cliSelect = require('cli-select'); 2const chalk = require('chalk'); 3 4cliSelect({ 5 values: ['Major', 'Minor', 'Patch'], 6 valueRenderer: (value, selected) => { 7 if (selected) { 8 return chalk.underline(value); 9 } 10 11 return value; 12 }, 13}).then(...);
Todo: more examples, also the one in the preview gif
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/23 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
31 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More