Unclear behavior with defaultOption and more-than-one multiple args
See original GitHub issueIssue Description
Given this config:
const optionDefinitions = [
{ name: 'verbose', alias: 'v', type: Boolean },
{ name: 'src', type: String, multiple: true },
{ name: 'foo', type: String, multiple: true, defaultOption: true },
{ name: 'timeout', alias: 't', type: Number }
]
It is not clear what would be the behavior for:
$ example --verbose --timeout=1000 --src one.js two.js three.js
What’s clear here:
one.js
is one of thesrc
values.
What’s not clear here:
- Are
two.js
andthree.js
values forsrc
, orfoo
?
The common-best-practice (specifically in unix-like systems) is to have two.js
and three.js
as foo
values. However, the examples in README.md
have a light indication that these values would be considered as src
’s. (At least some people that I have talked to have had this understanding from the doc.)
Would be great if we could make this more clear in the docs.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Invalid syntax. Default option is not allowed more than '2' time(s)
It is quite simple but hidden. run setx /? and I suppose the answer is there. The PATH you give as a parameter...
Read more >List of cognitive biases - Wikipedia
Cognitive biases are systematic patterns of deviation from norm and/or rationality in judgment. They are often studied in psychology, sociology and ...
Read more >Bash Reference Manual - GNU.org
This includes arguments to builtin commands such as declare that accept assignment statements (declaration commands). When ' += ' is applied to ...
Read more >CommandLine 2.0 Library Manual - Documentation - LLVM
Introduction¶. This document describes the CommandLine argument processing library. It will show you how to use it, and what it can do.
Read more >survival.pdf
Arguments formula a formula object, with the response on the left of a '~' operator and the terms, separated by + operators, on...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
the majority of users don’t quote glob expressions, meaning the shell expands the glob expression before passing the result into node… this results in command-line-args parsing a
process.argv
looking something like['-p', 'more-plugins/one.js', 'more-plugins/two.js', 'more-plugins/three.js']
(i.e. an option followed by one or more values)… We need to support this form…Use
lazyMultiple
to get this syntax form in command-line-args…Thanks for the feedback - if you have ideas to improve the documentation, feel free to edit the wiki or submit a PR… i too will review the docs when I get round to working on the next version…
So, in POSIX proper, enabling multiple plugins would be like
-p first.js -p second.js -p "more-plugins/*.js"
(the command would be responsible for glob expansion).And GNU adds the long options (doube-hyphen), allowing
--plugin first.js --plugin second.js ...
.https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
I think the idea is that if you expect many arguments of some kind, you would make sure there’s a short form for it, keeping the overhead low.
That said, the POSIX and GNU behaviors are kind of ancient now, and some newer major products actually use something a bit more flexible than that. However, I’m not familiar with any major system behavior the way this project does.
I wanted to refer to the docs for Rust’s clap library on how they handle multiple occurrences (which I believe should be GNU-friendly), however I couldn’t find it in the docs, and I think we need to write a demo for it to show how it behaves… (https://docs.rs/clap/latest/clap/)