Skip to content

Commit 8c0bcad

Browse files
authored
ArgParser: Improve missing subcommand error message (#12646)
Show attempted subcommand name in error message.
1 parent 9098506 commit 8c0bcad

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/tscore/ArgParser.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,13 @@ ArgParser::Command::parse(Arguments &ret, AP_StrVec &args)
707707
}
708708
// check for command required
709709
if (!flag && _command_required) {
710-
help_message("No subcommand found for " + _name);
710+
std::ostringstream msg;
711+
if (!args.empty()) {
712+
msg << "No sub-command '" << args[0] << "' found for " << _name;
713+
} else {
714+
msg << "No sub-command found for " << _name;
715+
}
716+
help_message(msg.str());
711717
}
712718
if (_name == parser_program_name) {
713719
// if we are at the top level

0 commit comments

Comments
 (0)