Skip to content

Commit

Permalink
Add --help flag to rungenmain, fixing #5323 (#6354)
Browse files Browse the repository at this point in the history
  • Loading branch information
abadams committed Oct 26, 2021
1 parent 06a37ca commit 6211da9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/RunGenMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ Usage: $NAME$ argument=value [argument=value... ] [flags]
Flags:
--help:
print this message and exit.
--describe:
print names and types of all arguments to stdout and exit.
Expand Down Expand Up @@ -325,6 +328,13 @@ int main(int argc, char **argv) {
std::vector<std::string> v = split_string(p, "=");
std::string flag_name = v[0];
std::string flag_value = v.size() > 1 ? v[1] : "";
// Check for the help flag early so that it takes
// precedence over other errors that occur before full
// argument parsing.
if (flag_name == "help") {
usage(argv[0]);
return 0;
}
if (v.size() > 2) {
fail() << "Invalid argument: " << argv[i];
}
Expand Down

0 comments on commit 6211da9

Please sign in to comment.