Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
cli-list-select
Advanced tools
Simple command line interactive list
npm i cli-list-select
Package exports single function
const list = require('cli-list-select');
Function is async and has 2 arguments.
Function arguments
Name | Type | Description |
---|---|---|
items | any[] | items to be displayed |
options? | Option | options |
Returns Result
Field | Type | Default | Description |
---|---|---|---|
printItem | (item: any, index: number, isFocused: bool, isChecked: bool) => string | String | function that provides string representation for an item |
index | number | 0 | initial focus position |
singleCheck | bool | false | tells if only one item can be checked |
checks | number[] | number | [] | NaN | initially checked items |
handlers | Handlers | {} | custom key handlers |
It is a map.
Field | Type | Description |
---|---|---|
key | string | key name |
value | (arg: HandlerArg) => void | key handler |
Default handlers are
Key | Handler |
---|---|
up | move focus to previous item |
down | move focus to next item |
space | toggle check of the focused item |
return | close the list |
Field | Type | Description |
---|---|---|
index | number | current focus |
setIndex | (index: number) => void | function that sets current focus |
toggleCheck | (index: number) => void | function that toggles check state of an item |
end | (note: any) => void | function that closes the list |
Field | Type | Description |
---|---|---|
index | number | focus |
checks | number[] | number | checked items |
note | any | note returned in the end function |
await list(['A', 'B', 'C']);
-[ ] A
[ ] B
[ ] C
await list(['A', 'B', 'C'], { index: 1 });
[ ] A
-[ ] B
[ ] C
[*] A
-[*] B
[ ] C
await list(['A', 'B', 'C'], { singleCheck: true });
[ ] A
-[*] B
[ ] C
await list(['A', 'B', 'C'], { checks: [0, 2] });
-[*] A
[ ] B
[*] C
await list([{ data: 'A' }, { data: 'B' }, { data: 'C' }], {
printItem: item => `<${item.data}>`
});
-[ ] <A>
[ ] <B>
[ ] <C>
await list(['A', 'B', 'C'], {
handlers: {
'q': ({ end }) => end('Q'),
},
});
FAQs
Simple command line interactive list
The npm package cli-list-select receives a total of 1 weekly downloads. As such, cli-list-select popularity was classified as not popular.
We found that cli-list-select demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.