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 program produces an incorrect usage when mutually exclusive groups contain (optional) positional arguments. For example,
Parser Definition:
auto mutex1 = parser.addMutuallyExclusiveGroup();
auto mutex2 = parser.addMutuallyExclusiveGroup();
mutex2.addArgument<int>("c")
.nargs(NArgsOption::OPTIONAL);
mutex1.addArgument<int>("a")
.nargs(NArgsOption::OPTIONAL);
mutex1.addArgument<string>("-b");
mutex2.addArgument<string>("-d");
Usage:
Usage: Argparse [[<int a>] | -B <string B>] [[<int c>] | -D <string D>]
Description:
ArgParse package sandbox
Positional Arguments:
int c
int a
Options:
string -B B
string -D D
The error is that argument c should be before a, but the mutex grouping does not know how to order the groups properly. Worse still, sometimes it is just not possible to get the right order. Consider if the first group contains positional arguments 1 and 3, and the second group contains positional argument 2.
Fortunately, this should be an edge case error since it is more intuitive to define the arguments in the same groups together, thereby preventing such bad ordering from happening in the first place.
Proposed Fix
I've looked at how Python argparse handles this, and it seems like they choose to respect the positional order at the cost of breaking argument grouping. This should not be hard, but it is a bit tedious. Therefore, I've chosen to open this issue instead of trying to fix it now.
The text was updated successfully, but these errors were encountered:
Synopsis
The program produces an incorrect usage when mutually exclusive groups contain (optional) positional arguments. For example,
Parser Definition:
Usage:
The error is that argument
c
should be beforea
, but the mutex grouping does not know how to order the groups properly. Worse still, sometimes it is just not possible to get the right order. Consider if the first group contains positional arguments 1 and 3, and the second group contains positional argument 2.Fortunately, this should be an edge case error since it is more intuitive to define the arguments in the same groups together, thereby preventing such bad ordering from happening in the first place.
Proposed Fix
I've looked at how Python
argparse
handles this, and it seems like they choose to respect the positional order at the cost of breaking argument grouping. This should not be hard, but it is a bit tedious. Therefore, I've chosen to open this issue instead of trying to fix it now.The text was updated successfully, but these errors were encountered: