Initial commit
[yaffs-website] / node_modules / grunt-contrib-sass / node_modules / dargs / readme.md
1 # dargs [![Build Status](https://travis-ci.org/sindresorhus/dargs.svg?branch=master)](https://travis-ci.org/sindresorhus/dargs)
2
3 > Reverse [`minimist`](https://github.com/substack/minimist). Convert an object of options into an array of command-line arguments.
4
5 Useful when spawning command-line tools.
6
7
8 ## Install
9
10 ```
11 $ npm install --save dargs
12 ```
13
14
15 #### Usage
16
17 ```js
18 const dargs = require('dargs');
19
20 const input = {
21         _: ['some', 'option'],          // values in '_' will be appended to the end of the generated argument list
22         foo: 'bar',
23         hello: true,                    // results in only the key being used
24         cake: false,                    // prepends `no-` before the key
25         camelCase: 5,                   // camelCase is slugged to `camel-case`
26         multiple: ['value', 'value2'],  // converted to multiple arguments
27         pieKind: 'cherry',
28         sad: ':('
29 };
30
31 const excludes = ['sad', /.*Kind$/];  // excludes and includes accept regular expressions
32 const includes = ['camelCase', 'multiple', 'sad', /^pie.*/];
33 const aliases = {file: 'f'};
34
35 console.log(dargs(input, {excludes: excludes}));
36 /*
37 [
38         '--foo=bar',
39         '--hello',
40         '--no-cake',
41         '--camel-case=5',
42         '--multiple=value',
43         '--multiple=value2',
44         'some',
45         'option'
46 ]
47 */
48
49 console.log(dargs(input, {
50         excludes: excludes,
51         includes: includes
52 }));
53 /*
54 [
55         '--camel-case=5',
56         '--multiple=value',
57         '--multiple=value2'
58 ]
59 */
60
61
62 console.log(dargs(input, {includes: includes}));
63 /*
64 [
65         '--camel-case=5',
66         '--multiple=value',
67         '--multiple=value2',
68         '--pie-kind=cherry',
69         '--sad=:('
70 ]
71 */
72
73
74 console.log(dargs({
75         foo: 'bar',
76         hello: true,
77         file: 'baz'
78 }, {
79         aliases: aliases
80 }));
81 /*
82 [
83         '--foo=bar',
84         '--hello',
85         '-f baz'
86 ]
87 */
88 ```
89
90 ## API
91
92 ### dargs(input, [options])
93
94 #### input
95
96 Type: `object`
97
98 Object to convert to command-line arguments.
99
100 #### options
101
102 Type: `object`
103
104 ##### excludes
105
106 Type: `array`
107
108 Keys or regex of keys to exclude. Takes precedence over `includes`.
109
110 ##### includes
111
112 Type: `array`
113
114 Keys or regex of keys to include.
115
116 ##### aliases
117
118 Type: `object`
119
120 Maps keys in `input` to an aliased name. Matching keys are converted to options with a single dash ("-") in front of the aliased name and a space separating the aliased name from the value. Keys are still affected by `includes` and `excludes`.
121
122 ##### useEquals
123
124 Type: `boolean`  
125 Default: `true`
126
127 Setting to `false` switches the separator in generated commands from an equals sign `=` to a single space ` `. For example:
128
129 ```js
130 console.log(dargs({foo: 'bar'}, {useEquals: false}));
131 /*
132 [
133     '--foo bar'
134 ]
135 */
136 ```
137
138 ##### ignoreFalse
139
140 Type: `boolean`  
141 Default: `false`
142
143 Don't include `false` values. This is mostly useful when dealing with strict argument parsers that would throw on unknown arguments like `--no-foo`.
144
145
146 ## License
147
148 MIT © [Sindre Sorhus](http://sindresorhus.com)