Command line argument parser
$ npm install argz-parze
There is a single function exposed which takes an array,
this would be akin to process.argv.slice(2)
, and returns an object.
An underscore key holds arguments provided after a terminating sequence '--'
and arguments passed without a hyphen type.
const parse = require('argz-parse')
> parse(['-a', 'hey', '-b', 'foo'])
{ _: [], a: 'hey', b: 'foo' }
> parse(['-abc', 'hi'])
{ _: [], c: 'hi', a: true, b: true }
> parse(['--foo', '--bar=3'])
{ _: [], bar: 3, foo: true }
> parse(['--foo', '--bar=baz', '-mtv', '--', 'hello', 'world'])
{ _: [ 'hello', 'world' ],
bar: 'baz',
foo: true,
m: true,
t: true,
v: true }
MIT