File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ var subarg = require ( '../' ) ;
2
+ var argv = subarg ( process . argv . slice ( 2 ) ) ;
3
+ console . log ( argv ) ;
Original file line number Diff line number Diff line change
1
+ # subarg
2
+
3
+ parse arguments with recursive contexts using
4
+ [ minimist] ( https://npmjs.org/package/minimist )
5
+
6
+ This module is useful if you need to pass arguments into a piece of code without
7
+ coordinating ahead of time with the main program, like with a plugin system.
8
+
9
+ # example
10
+
11
+ ``` js
12
+ var subarg = require (' subarg' );
13
+ var argv = subarg (process .argv .slice (2 ));
14
+ console .log (argv);
15
+ ```
16
+
17
+ Contexts are denoted with square brackets:
18
+
19
+ ```
20
+ $ node example/show.js beep --beep [ boop -a 3 ] -n4 --robots [ -x 8 -y 6 ]
21
+ { _: [ 'beep', ']' ],
22
+ beep: { _: [ 'boop' ], a: 3 },
23
+ n: 4,
24
+ robots: '[',
25
+ x: 8,
26
+ y: 6 }
27
+ ```
28
+
29
+ # methods
30
+
31
+ ``` js
32
+ var subarg = require (' subarg' )
33
+ ```
34
+
35
+ ## var argv = subarg(args, opts)
36
+
37
+ Parse the arguments array ` args ` , passing ` opts ` to
38
+ [ minimist] ( https://npmjs.org/package/minimist ) .
39
+
40
+ An opening ` [ ` in the ` args ` array creates a new context and a ` ] ` closes a
41
+ context. Contexts may be nested.
42
+
43
+ # install
44
+
45
+ With [ npm] ( https://npmjs.org ) do:
46
+
47
+ ```
48
+ npm install subarg
49
+ ```
50
+
51
+ # license
52
+
53
+ MIT
You can’t perform that action at this time.
0 commit comments