You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The string values are parsed correctly in case of boolean or number values, but are not in case of array. Something like https://github.com/mccormicka/string-argv could be used to parse strings into arrays(simple parsing might not work because quotes must be considered, too).
@le0nik@JaKXz having revisited this, my feeling is that this behavior is actually reasonable -- although we may want to document it somewhere?
My expectation with .config is that that the object passed would already have split arrays and objects out, so something like this:
.config({foo: ["a","b"],bar: {a: 99,b: 33}})
This makes it easy to load a JSON configuration file of disk and use it to populate yargs. tldr; I don't think we should think of the values passed to .config as unparsed command line values, rather they're an intermediate JSON representation.
Original issue: yargs/yargs#789.
The string values are parsed correctly in case of
boolean
ornumber
values, but are not in case of array. Something like https://github.com/mccormicka/string-argv could be used to parse strings into arrays(simple parsing might not work because quotes must be considered, too).Passed through cli:
$ node ./test.js --arr foo bar
Outputs:
argv { _: [], arr: [ 'foo', 'bar' ], '$0': 'test.js' }
Passed through
.config()
$ node ./test.js
Outputs:
argv { _: [], arr: [ 'foo bar' ], '$0': 'test.js' }
yargs@6.6.0
The text was updated successfully, but these errors were encountered: