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
I am trying to allow the following kind of command line uses:
<optionnotspecified> yields default value (e.g., {""})
--option with no argument yields implicit value (e.g., {"all"})
--option a yields {"a"}
--option a --option b yields {"a", "b"}
Instead, #3 yields {"all"} and #4 yields {"all", "all"}. It seems using implicit_value forces the user to use the --option=a,b syntax. Is this intended?
This is a problem that often comes up, and I don't know if there are any better ways to solve this. The problem with implicit options is that the parser can't tell if the next option is supposed to be attached to the implicit option or is a standalone argument (positional argument). So it basically forces you to use =. In your example 4, it's the same as writing
--option --option a b
which gives you (all, all) for --option, and two positional arguments a and b.
Thanks for your reply. I don't tend to use positional arguments. Perhaps a solution would be a mode where any positional arguments must follow a specific switch (typically --). In that mode, any arguments not beginning with - are parsed as appending to the vector associated to the previous switch. The preceding switch would have to be a vector or there would be a parse error.
Anyway, I understand this is a minor limitation and a new mode may not be feasible or desired. Thanks for your response and for sharing this useful tool!
I am trying to allow the following kind of command line uses:
{""}
)--option
with no argument yields implicit value (e.g.,{"all"}
)--option a
yields{"a"}
--option a --option b
yields{"a", "b"}
Instead, #3 yields
{"all"}
and #4 yields{"all", "all"}
. It seems usingimplicit_value
forces the user to use the--option=a,b
syntax. Is this intended?Here is my code fragment. I am using v3.2.1.
Thank you for any guidance.
The text was updated successfully, but these errors were encountered: