brbzull0 commented on code in PR #13862:
URL: https://github.com/apache/trafficserver/pull/13862#discussion_r4627844836
##########
src/tscore/ArgParser.cc:
##########
@@ -235,6 +240,32 @@ ArgParser::parse(const char **argv)
}
command->help_message(msg);
}
+ // A token an option took as its value was written for a command dispatched
below that
+ // option's command when it names one of that command's options and comes
after its name:
+ // only there could that command have received it. The line is checked only
now that it has
+ // parsed, so a line refused for another reason, or one asking for help or
the version, is
+ // answered as it always was. The default command inserted above is not on
the line, so its
+ // name comes before nothing.
+ for (auto const &value : trace.values) {
+ std::string const &token = _argv[value.pos];
+ bool below = false;
+
+ for (auto const &[command, name_pos] : trace.dispatched) {
+ if (command == value.owner) {
+ below = true;
+ } else if (below && name_pos >= 0 && name_pos < value.pos &&
command->is_registered_option(token)) {
Review Comment:
Not changing this: a value never has position -1. Only a token taken as the
value of an option, and starting with `-`, is recorded. The default command is
inserted right after the program name, so no option can come before it to take
it as a value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]