cli-list

Parse comma-separated argument lists.

Showing:

Popularity

Downloads/wk

82.1K

GitHub Stars

8

Maintenance

Last Commit

2yrs ago

Contributors

3

Package

Dependencies

0

License

MIT

Type Definitions

Tree-Shakeable

No?

Readme

cli-list

Break CLI lists into arrays

build status downloads

Given a "CLI list" like so:

foo bar, baz --qux, oof

We can expect process.argv to be something such as:

['foo', 'bar,', 'baz', '--qux,', 'oof']

If we run this through the cli-list function we can split it into sub-arrays where the commas are:

[['foo', 'bar'], ['baz', '--qux'], ['oof']]

Theses arrays maintain the process.argv style, so they can be used in parity with things like minimist.

Installation

$ npm install --save cli-list

Usage

var list = require('cli-list');
var opts = list(process.argv.slice(2));

ES6 + Minimist:

import list from 'cli-list';
import minimist from 'minimist';
const opts = list(process.argv.slice(2)).map(item => minimist(item));

Examples

Given:

$ test foo --bar, baz, --qux

Expect:

[['foo', '--bar'], ['baz'], ['--qux']]

Credits

jamen
Jamen Marzonie

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Tutorials

No tutorials found
Add a tutorial