package
Break CLI lists into arrays
npm install cli-listGitHub-flavored package documentation.
Across all versions, last 30 days.
1,796,634 in 30 days
Runtime metadata.
Break CLI lists into arrays
Given a "CLI list" like so:
foo bar, baz --qux, oofWe 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.
$ npm install --save cli-listvar 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));Given:
$ test foo --bar, baz, --quxExpect:
[['foo', '--bar'], ['baz'], ['--qux']]jamen
jamenmarz@gmail.com
Estimated unpacked size across 1 packages.
3.3 kB
Includes dependencies.