Open bradisbell opened 8 years ago
@bradisbell Thanks for reporting!
This seems to be a bug with yargs-parser:
var parse = require('yargs-parser')
var argv = parse(process.argv.slice(2), {
array: 'arrOption'
})
console.log(argv)
$ node issue621.js --arrOption "-val1" "-val2" "-val3"
{ _: [],
arrOption: [],
v: [ true, true, true ],
a: [ true, true, true ],
l: [ 1, 2, 3 ] }
$ node issue621.js --arrOption "-val1" --arrOption "-val2" --arrOption "-val3"
{ _: [],
arrOption: [ [], [] ],
v: [ true, true, true ],
a: [ true, true, true ],
l: [ 1, 2, 3 ] }
$ node issue621.js --arrOption="-val1" --arrOption="-val2" --arrOption="-val3"
{ _: [],
arrOption: [ [], '-val3' ],
v: [ true, true ],
a: [ true, true ],
l: [ 1, 2 ] }
Oddly enough, I can produce the desired result if I don't explicitly define the option as an array type:
// yargs-parser
var parse = require('yargs-parser')
var argv = parse(process.argv.slice(2))
console.log(argv)
// or yargs
argv = require('yargs').argv
console.log(argv)
$ node issue621.js --arrOption="-val1" --arrOption="-val2" --arrOption="-val3"
{ _: [], arrOption: [ '-val1', '-val2', '-val3' ] }
{ _: [],
arrOption: [ '-val1', '-val2', '-val3' ],
'$0': 'issue621.js' }
But that's certainly not acceptable. Sounds similar to yargs/yargs-parser#145, we'll need to fix this in yargs-parser.
I have this issue as well, any update @nexdrew ?
Is there any workaround for this?
is there a fix on this issue?
I need to pass in an array of values that have hyphens. I can't seem to figure out the required syntax.
Desired result:
How can I achieve this?