command-args

2.0.3 • Public • Published

dargs Build Status

Convert an object of options into an array of command-line arguments

Basically the inverse of an argument parser like minimist. Useful when spawning command-line tools.

Install

$ npm install --save dargs

Usage

var dargs = require('dargs');
 
var options = {
    foo: 'bar',
    hello: true,                    // results in only the key being used
    cake: false,                    // ignored
    camelCase: 5,                   // camelCase is slugged to `camel-case`
    multiple: ['value', 'value2'],  // converted to multiple arguments
    sad: ':('
};
 
var excludes = ['sad'];
 
console.log(dargs(options, excludes));
 
/*
[
    "--foo=bar",
    "--hello",
    "--camel-case=5",
    "--multiple=value",
    "--multiple=value2"
]
*/

API

dargs(options, excludes)

options

Type: object

Options to convert to command-line arguments.

excludes

Type: array

Keys to exclude.

License

MIT © Sindre Sorhus

Package Sidebar

Install

npm i command-args

Weekly Downloads

1

Version

2.0.3

License

MIT

Last publish

Collaborators

  • dengzhao