parse arguments with recursive contexts using minimist
This module is useful if you need to pass arguments into a piece of code without coordinating ahead of time with the main program, like with a plugin system.
var subarg = require('subarg');
var argv = subarg(process.argv.slice(2));
console.log(argv);
Contexts are denoted with square brackets:
$ node example/show.js rawr --beep [ boop -a 3 ] -n4 --robots [ -x 8 -y 6 ]
{ _: [ 'rawr' ],
beep: { _: [ 'boop' ], a: 3 },
n: 4,
robots: { _: [], x: 8, y: 6 } }
var subarg = require('subarg')
Parse the arguments array args
, passing opts
to
minimist.
An opening [
in the args
array creates a new context and a ]
closes a
context. Contexts may be nested.
With npm do:
npm install subarg
MIT
# subarg parse arguments with recursive contexts using [minimist](https://npmjs.org/package/minimist) [![testling badge](https://ci.testling.com/substack/subarg.png)](https://ci.testling.com/substack/subarg) [![build status](https://secure.travis-ci.org/substack/subarg.png)](http://travis-ci.org/substack/subarg) This module is useful if you need to pass arguments into a piece of code without coordinating ahead of time with the main program, like with a plugin system. # example ``` js var subarg = require('subarg'); var argv = subarg(process.argv.slice(2)); console.log(argv); ``` Contexts are denoted with square brackets: ``` $ node example/show.js rawr --beep [ boop -a 3 ] -n4 --robots [ -x 8 -y 6 ] { _: [ 'rawr' ], beep: { _: [ 'boop' ], a: 3 }, n: 4, robots: { _: [], x: 8, y: 6 } } ``` # methods ``` js var subarg = require('subarg') ``` ## var argv = subarg(args, opts) Parse the arguments array `args`, passing `opts` to [minimist](https://npmjs.org/package/minimist). An opening `[` in the `args` array creates a new context and a `]` closes a context. Contexts may be nested. # install With [npm](https://npmjs.org) do: ``` npm install subarg ``` # license MIT
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/subarg/readme.markdown | |||||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |