Debian Codegraph @

readme.markdown

raw
1 # subarg
2
3 parse arguments with recursive contexts using
4 [minimist](https://npmjs.org/package/minimist)
5
6 [![testling badge](https://ci.testling.com/substack/subarg.png)](https://ci.testling.com/substack/subarg)
7
8 [![build status](https://secure.travis-ci.org/substack/subarg.png)](http://travis-ci.org/substack/subarg)
9
10 This module is useful if you need to pass arguments into a piece of code without
11 coordinating ahead of time with the main program, like with a plugin system.
12
13 # example
14
15 ``` js
16 var subarg = require('subarg');
17 var argv = subarg(process.argv.slice(2));
18 console.log(argv);
19 ```
20
21 Contexts are denoted with square brackets:
22
23 ```
24 $ node example/show.js rawr --beep [ boop -a 3 ] -n4 --robots [ -x 8 -y 6 ]
25 { _: [ 'rawr' ],
26 beep: { _: [ 'boop' ], a: 3 },
27 n: 4,
28 robots: { _: [], x: 8, y: 6 } }
29 ```
30
31 # methods
32
33 ``` js
34 var subarg = require('subarg')
35 ```
36
37 ## var argv = subarg(args, opts)
38
39 Parse the arguments array `args`, passing `opts` to
40 [minimist](https://npmjs.org/package/minimist).
41
42 An opening `[` in the `args` array creates a new context and a `]` closes a
43 context. Contexts may be nested.
44
45 # install
46
47 With [npm](https://npmjs.org) do:
48
49 ```
50 npm install subarg
51 ```
52
53 # license
54
55 MIT