-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add an opts.array #65
Comments
Related, Deno has made the array behaviour explicit with |
I would prefer arrays to be parsed without having to specify the arg name for each array value, e.g. Perhaps there could be 2 new options: |
That seems very strange, and not what I'm familiar with from yargs. Options - single or double dashed - are only ever followed by a single value, and it seems very surprising to allow an interface that deviates from that. In yargs, I typically do |
const yargsFactory = require('yargs/yargs')
const argv = yargsFactory(process.argv.slice(2))
.array('arr')
.parse();
console.log(argv); % node arr.js --arr 1 2 3
{ _: [], arr: [ 1, 2, 3 ], '$0': 'arr.js' } Greedy arrays work ok if there are not positional arguments. When there might be positional arguments it leads to ambiguous parsing. With |
My assumption would be that it's decided by however the Since I'm out of my depth here as a non-CLI argument/option patterns and practices expert, I'll just leave you with a description of what I wanted to do yesterday and why: TLDR; One of the options I was trying to add to my script was Backstory: I wanted to add some nice CLI options to my reusable esbuild script and make it easy for the other devs to use. I started out with Yargs because I had used it in the past. As I re-familiarized myself with it's API, I started realizing it was way too complex to simply add some options to a script. I didn't need a whole command-group based parser with 7 dependencies, just a simple options parser. Unfortunately I didn't look more closely at those 7 dependencies because then I might have realized that I could have just used As I shifted over to using |
An issue from the original Minimist repo from @stevendesu with 11 upvotes
https://web.archive.org/web/20200904203616/https://github.com/substack/minimist/issues/136/
I have a command line argument that I wish to always be an array, but it may only contain one value:
Current Behavior
Desired New Option
The text was updated successfully, but these errors were encountered: