object-to-argv

Convert an object to an array of arguments to pass to a cli process
Note: object-to-argv
is only supported on iojs and node v4+. To use with
an older version of node, please use object-to-argv@1
.
Install
$ npm install object-to-argv
Test
$ npm test
API
objectToArgv(obj:Object, [opts:Object])
If obj
is not an object, it is coerced to one.
opts
can contain the following keys:
equalSign
: will format like ['--name=evan']
vs ['--name', 'evan']
alwaysSingle
: will always use single dashes like ['-name', 'evan']
Example
const convert = require('object-to-argv')
const input = {
name: 'evan'
, debug: true
, verbose: false
, test: {}
, test: null
, b: true
, n: 'evan'
}
console.log(convert(input))
const input2 = {
name: 'evan'
, debug: true
, verbose: false
, test: {}
, test: null
, b: true
, n: 'evan'
}
console.log(convert(input2, {
alwaysSingle: true
}))
const input3 = {
name: 'evan'
, debug: true
, verbose: false
, test: {}
, test: null
, b: true
, n: 'evan'
}
console.log(convert(input3, {
equalSign: true
}))
const input4 = {
name: 'evan'
, debug: true
, verbose: false
, test: {}
, test: null
, b: true
, n: 'evan'
}
console.log(convert(input4, {
alwaysSingle: true
, equalSign: true
}))
Author
Evan Lucas
License
MIT (See LICENSE
for more info)