cli-list
Break CLI lists into arrays
Last updated 2 years ago by sboudrias .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install cli-list 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

10 Versions

  • 1.0.0                                ...           2 years ago
  • 0.2.0                                ...           10 years ago
  • 0.1.8                                ...           11 years ago
  • 0.1.7                                ...           11 years ago
  • 0.1.6                                ...           11 years ago
  • 0.1.5                                ...           11 years ago
  • 0.1.4                                ...           11 years ago
  • 0.1.3                                ...           11 years ago
  • 0.1.2                                ...           11 years ago
  • 0.1.1                                ...           11 years ago
Maintainers (2)
Downloads
Total 27
Today 0
This Week 1
This Month 11
Last Day 0
Last Week 2
Last Month 10
Dependencies (0)
None
Dev Dependencies (5)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE