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
Also, "optionally accept" 1 param means "take the next param, except if it looks like another named arg" (like greedy consuming of params, but for 1)!
All would be still configurable, of course, incl. having the current behavior exactly. It's just about more intuitive defaults.
The current default of short options being just nullary predicates* has bitten me at OON, with -C cfgfile "not working"...
The new defaults may sound like a convoluted, arbitrary rule, but may be more intuitive actually, as positional args. are
rarely intermixed with named ones in practice (they tend to come after the "switches")!
One big problem, though: during the parsing loop there's no way to know in advance that the "last one" is actually the last one, so that might mean reparsing that whole chunk! Which, well, could be reduced to
a) flag every "non-rule-driven" (i.e. implicit-arity) short option as "tentatively last" (for later massaging)
b remove that flag if another named arg comes (either explicit (rule-driven), or implicit (default))
c) when finished, if there's a "tentatively last" named option, take its param away (assert that it has one, or there's no positional args at all!), and add it to the positionals
And another, possibly even a show-stopper for this change: this would prevent intermixing named and unnamed options at all, without requiring to define rules for each (named) option! :-o
But... This may just be how command-line args should actually work? I can't come up right away with a practical example, where unnamed options are not in fact just params of some named arg. But scripts that need to tuck positional args at the end of half-assembled command strings, without knowing what came before, may suffer!
Implement it anyway, and take it for a long test ride!
* Wait, no... :-o This is what the general test case says:
RUN args-test.exe --one 99 2 3 4 -i a b c -h --long=1
EXPECT "\
-------- NAMED:
h
i = a, b, c
...
WTF is going on then? :-o
Arrrghs!... :) The test exe has non-default rules, and has -i defined as greedy!
The text was updated successfully, but these errors were encountered:
xparq
changed the title
Change short options to accept 1 param by default, except the last one, which should take none
Change short options to "optionally accept" 1 param by default, except the last one, which should take none
Nov 1, 2023
xparq
changed the title
Change short options to "optionally accept" 1 param by default, except the last one, which should take none
Change short options to "optionally accept" 1 param by default, except the last one, which should take none...?
Nov 1, 2023
All would be still configurable, of course, incl. having the current behavior exactly. It's just about more intuitive defaults.
The current default of short options being just nullary predicates* has bitten me at OON, with
-C cfgfile
"not working"...The new defaults may sound like a convoluted, arbitrary rule, but may be more intuitive actually, as positional args. are
rarely intermixed with named ones in practice (they tend to come after the "switches")!
One big problem, though: during the parsing loop there's no way to know in advance that the "last one" is actually the last one, so that might mean reparsing that whole chunk! Which, well, could be reduced to
And another, possibly even a show-stopper for this change: this would prevent intermixing named and unnamed options at all, without requiring to define rules for each (named) option! :-o
But... This may just be how command-line args should actually work? I can't come up right away with a practical example, where unnamed options are not in fact just params of some named arg. But scripts that need to tuck positional args at the end of half-assembled command strings, without knowing what came before, may suffer!
* Wait, no... :-o This is what the
general
test case says:WTF is going on then? :-o
Arrrghs!... :) The test exe has non-default rules, and has -i defined as greedy!
The text was updated successfully, but these errors were encountered: