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
The issue is that Argument::consume() consumes the foo value when parsing --a.
I believe that in the general case, such parser will be ambiguous. It can be de-ambiguated at least (only?) in the following particular situation: when the positional arguments have a fixed number of values each.
I was also thinking about criteria based on the typing of the arguments. For example if we know that the type of a --a value is a number whereas the type of the positional argument is a non-number strings, but that gets really complicated.
So what are our potential options to resolve the issue:
just documenting the issue in user documentation?
add a ArgumentParser::validate() method (independent of the actual argv[] values), possibly called by parse_args() at its beginnings, that would throw in situations where it detects the set of arguments is ambiguous? That is when there are optional arguments with a varying number of values, and also positional arguments with at least one with a varying number of values.
add an optional callback to a Argument where it can return if it recognizes the provided string as a valid value for it? (would work in situations where the values of the optional argument with a varying number of values is numeric, whereas the first positional argument can't be)
The text was updated successfully, but these errors were encountered:
WHEN("provided many arguments followed by an option with many arguments") {
. But this requires specifying the optional argument after the positional one(s). Which doesn't match the advertize usage: Usage: test [--help] [--version] [-s VAR...] [input]...
We give the user the full power, it's similar to dynamic memory allocation in C++ (User is responsible for de-allocation) before smart pointers.
Positional arguments after Optional arguments will not always cause an issue (It's our design we shall first process positional arguments before optional ones to avoid such a scenario or forcing user to specify number of values for optional arguments).
./mytest --a 1 2 foo in this example, foo will be consumed by --b option.
Consider the following parser
The following invocations work:
but not
The issue is that Argument::consume() consumes the
foo
value when parsing--a
.I believe that in the general case, such parser will be ambiguous. It can be de-ambiguated at least (only?) in the following particular situation: when the positional arguments have a fixed number of values each.
I was also thinking about criteria based on the typing of the arguments. For example if we know that the type of a --a value is a number whereas the type of the positional argument is a non-number strings, but that gets really complicated.
So what are our potential options to resolve the issue:
The text was updated successfully, but these errors were encountered: