JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7547801
  • Score
    100M100P100Q208818F
  • License MIT

Reverse minimist. Convert an object of options into an array of command-line arguments.

Package Exports

  • dargs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dargs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

dargs Build Status

Reverse minimist. Convert an object of options into an array of command-line arguments.

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,                    // prepends `no-` before the key
    camelCase: 5,                   // camelCase is slugged to `camel-case`
    multiple: ['value', 'value2'],  // converted to multiple arguments
    sad: ':('
};

var excludes = ['sad'];
var includes = ['camelCase', 'multiple', 'sad'];

console.log(dargs(options, excludes));
/*
[
    '--foo=bar',
    '--hello',
    '--no-cake',
    '--camel-case=5',
    '--multiple=value',
    '--multiple=value2'
]
*/

console.log(dargs(options, excludes, includes));
/*
[
    '--camel-case=5',
    '--multiple=value',
    '--multiple=value2'
]
*/


console.log(dargs(options, [], includes));
/*
[
    '--camel-case=5',
    '--multiple=value',
    '--multiple=value2',
    '--sad=:(''
]
*/

API

dargs(options, excludes, includes)

options

Type: object

Options to convert to command-line arguments.

excludes

Type: array

Keys to exclude.
Takes precedence over includes.

includes

Type: array

Keys to include.

License

MIT © Sindre Sorhus