forked from trentm/node-dashdash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TODO.txt
43 lines (30 loc) · 1.06 KB
/
TODO.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# someday/maybe
- being able to add types: i.e. a validator (easy to do, just haven't exposed)
- Maybe this later: var opts = parser.parse({argv: process.argv});
# notes: supporting opts from env or from a file
Say I have a 'foo' tool with a '-v' option for verbose. I also want
FOO_VERBOSE envvar to set verbose:
$ foo -v
debug: blah blah
...
$ FOO_VERBOSE=1 foo
debug: blah blah
...
foo.js:
var dashdash = require('dashdash')
var options = [{name: 'v', env: 'FOO_VERBOSE', type: 'bool'}];
var parser = new dashdash.Parser({options: options});
var opts = parser.parse(process.argv);
Say, also a ~/.foorc file is supported (somewhat a la ~/.ackrc) where
the file holds extra CLI opts:
$ cat ~/.foorc
-v -i
--file=foo.txt
Parsing that would look like:
var options = [
{name: 'v', env: 'FOO_VERBOSE', type: 'bool'},
{name: 'i', type: 'bool'},
{name: 'file', env: 'FOO_FILE', type: 'string'}
];
var parser = new dashdash.Parser({options: options});
var opts = parser.parse(process.argv);