🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
d

dargs-object

Fork of https://github.com/sindresorhus/dargs. Converts an object of options into an array of command-line arguments. Useful when calling command-line tools. Now object-aware

0.2.0
latest
70

Supply Chain Security

100

Vulnerability

89

Quality

75

Maintenance

100

License

Unpopular package

Quality

This package is not very popular.

Found 1 instance in 1 package

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created

dargs-object

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

Basically the inverse of an argument parser like nopt or minimist.

Forked from https://github.com/sindresorhus/dargs

Install

$ npm install --save dargs-object

Example

var dargs = require('dargs-object');

var obj = {
	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
	object: {test:'value'},
	sad: ':('
};

var options={
	excludes:['sad'],
	convertCamelCase:true,
	joinLists:false
};
console.log(dargs(obj, options));

/*
[
	'--foo', 'bar',
	'--hello',
	'--camel-case', '5',
	'--multiple', 'value',
	'--multiple', 'value2',
	'--object.test', 'value'
]
*/

API

dargs(obj, options)

obj

Type: Object

an object containing options to convert to command-line arguments.

options

Type: Object

Properties:

  • excludes: Keys to exclude.
  • joinLists: If false (default), array values will generate multiple flags: '--list thing1 --list thing2 --list thing3'. If true, array values will be passed, delimited, to a single flag: '--list thing1,thing2,thing3'.
  • convertCamelCase (default: false): Convert camelCase flags to camel-case

License

MIT © Ryan Bridges, based off the original dargs by Sindre Sorhus

FAQs

Package last updated on 28 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts