1 # dargs [![Build Status](https://travis-ci.org/sindresorhus/dargs.svg?branch=master)](https://travis-ci.org/sindresorhus/dargs)
3 > Reverse [`minimist`](https://github.com/substack/minimist). Convert an object of options into an array of command-line arguments.
5 Useful when spawning command-line tools.
11 $ npm install --save dargs
18 const dargs = require('dargs');
21 _: ['some', 'option'], // values in '_' will be appended to the end of the generated argument list
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
31 const excludes = ['sad', /.*Kind$/]; // excludes and includes accept regular expressions
32 const includes = ['camelCase', 'multiple', 'sad', /^pie.*/];
33 const aliases = {file: 'f'};
35 console.log(dargs(input, {excludes: excludes}));
49 console.log(dargs(input, {
62 console.log(dargs(input, {includes: includes}));
92 ### dargs(input, [options])
98 Object to convert to command-line arguments.
108 Keys or regex of keys to exclude. Takes precedence over `includes`.
114 Keys or regex of keys to include.
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`.
127 Setting to `false` switches the separator in generated commands from an equals sign `=` to a single space ` `. For example:
130 console.log(dargs({foo: 'bar'}, {useEquals: false}));
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`.
148 MIT © [Sindre Sorhus](http://sindresorhus.com)