Initial commit
[yaffs-website] / 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 > Convert an object of options into an array of command-line arguments
4
5 Basically the inverse of an argument parser like minimist. Useful when spawning command-line tools.
6
7
8 ## Install
9
10 ```sh
11 $ npm install --save dargs
12 ```
13
14
15 #### Usage
16
17 ```js
18 var dargs = require('dargs');
19
20 var options = {
21         foo: 'bar',
22         hello: true,                    // results in only the key being used
23         cake: false,                    // ignored
24         camelCase: 5,                   // camelCase is slugged to `camel-case`
25         multiple: ['value', 'value2'],  // converted to multiple arguments
26         sad: ':('
27 };
28
29 var excludes = ['sad'];
30 var includes = ['camelCase', 'multiple', 'sad'];
31
32 console.log(dargs(options, excludes));
33 /*
34 [
35         '--foo=bar',
36         '--hello',
37         '--camel-case=5',
38         '--multiple=value',
39         '--multiple=value2'
40 ]
41 */
42
43 console.log(dargs(options, excludes, includes));
44 /*
45 [
46         '--camel-case=5',
47         '--multiple=value',
48         '--multiple=value2'
49 ]
50 */
51
52
53 console.log(dargs(options, [], includes));
54 /*
55 [
56         '--camel-case=5',
57         '--multiple=value',
58         '--multiple=value2',
59         '--sad=:(''
60 ]
61 */
62 ```
63
64 ## API
65
66 ### dargs(options, excludes, includes)
67
68 #### options
69
70 Type: `object`
71
72 Options to convert to command-line arguments.
73
74 #### excludes
75
76 Type: `array`
77
78 Keys to exclude.  
79 Takes precedence over `includes`.
80
81 #### includes
82
83 Type: `array`
84
85 Keys to include.
86
87 ## License
88
89 MIT © [Sindre Sorhus](http://sindresorhus.com)