yargs / yargs-parser

:muscle: the mighty option parser used by yargs
http://yargs.js.org/
ISC License
493 stars 118 forks source link

feat: should we provide a way for folks to filter whether or not an argument should be appended to an array #219

Open laggingreflex opened 7 years ago

laggingreflex commented 7 years ago

If you have a flag that takes an array, how to make it differentiate between the values that it's supposed take and those that should just be positional arguments?

For Eg.:

create-index --filetype .js .jsx ./src

Here filetype should only take .js .jsx and ./src should be a positional argument.

It seems this isn't currently possible, right? I haven't come across this kind of use case before so I'm not sure what should the solution to this be. Is this something that should even be solved at yargs level, or should the end-user just be advised to use the cli in a way to avoid this issue altogether (create-index ./src --filetype .js .jsx)

acwest commented 7 years ago

I have found (in version 9.0.1) that array parsing appears to return an array containing null if any other positional arguments are present

bcoe commented 4 years ago

moved to yargs-parser 👍