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
Taking a look at how implementations deal with option-arguments. Some made up terminology to describe the behaviours.
"greedy" vs "choosy" vs "embedded"
greedy: any value consumed with -w VALUE, including starting with hyphen
choosy: some values are rejected for -w VALUE, such as starting with hyphen
embedded: the only way to supply a value is embedded in the argument, like -wVALUE or --with=VALUE
"required" vs "optional"
required: the option requires an option-argument
optional: the option can be used with or without an option-argument
Taking a look at the reference specifications and implementations from #76
POSIX: describes "greedy required" and "embedded optional"
GNU: no changes getopt_long: "greedy required" and "embedded optional"
Commander: "greedy required" and "choosy optional"
Yargs: "choosy required" and "choosy optional"
Minimist: "choosy optional" (I didn't see how to make the option-argument required.)
Thinking about the target of this module to be used by a wide audience, I would go for the POSIX implementation first
This is where my head's at as well. Not only would following POSIX behavior ("greedy required" and "embedded optional") be familiar and widely understood by the community but it would align the parseArgs implementation to a standard (as opposed to contributors' opinions and observations of other libraries).
Also now that I think about it, with greedy and strict: false wouldn't authors have the most accurate user input (according to their options-configs) and thus be able to throw more informative errors: e.g.
Activity
Eomm commentedon Mar 12, 2022
I must say that I prefer the
choosy optional(maybe it is a habit).Thinking about the target of this module to be used by a wide audience, I would go for the
POSIXimplementation firstshadowspawn commentedon Mar 13, 2022
aaronccasanova commentedon Mar 13, 2022
This is where my head's at as well. Not only would following POSIX behavior ("greedy required" and "embedded optional") be familiar and widely understood by the community but it would align the
parseArgsimplementation to a standard (as opposed to contributors' opinions and observations of other libraries).Also now that I think about it, with
greedyandstrict: falsewouldn't authors have the most accurate user input (according to their options-configs) and thus be able to throw more informative errors: e.g.The best error handling the author can provide is:
Error: The '--foo' option expects a value.Whereas
greedyparse behavior would allow authors (who prefer BYO validation) to state exactly how the input was malformed: