Skip to content

Commit

Permalink
Fix for CR-1219106: Handling unrecognized commands for all utilities
Browse files Browse the repository at this point in the history
Signed-off-by: Akshay Tondak <[email protected]>
  • Loading branch information
Akshay Tondak authored and Akshay Tondak committed Feb 3, 2025
1 parent 48b3aa2 commit ebcadb6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/runtime_src/core/tools/common/XBMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,17 @@ void main_(int argc, char** argv,
// Parse the command line arguments
po::variables_map vm;
po::command_line_parser parser(argc, argv);
SubCmd::SubCmdOptions subcmd_options;
SubCmd::SubCmdOptions unrecognized_options;
try {
subcmd_options = XBU::process_arguments(vm, parser, allOptions, positionalCommand, false);
unrecognized_options = XBU::process_arguments(vm, parser, allOptions, positionalCommand, false);
if (!unrecognized_options.empty())
{
std::string error_str;
error_str.append("Unrecognized arguments:\n");
for (const auto& option : unrecognized_options)
error_str.append(boost::str(boost::format(" %s\n") % option));
throw boost::program_options::error(error_str);
}
} catch (po::error& ex) {
std::cerr << ex.what() << std::endl;
}
Expand Down Expand Up @@ -168,8 +176,7 @@ void main_(int argc, char** argv,
return;
}

// -- Prepare the data
subcmd_options.erase(subcmd_options.begin());
SubCmd::SubCmdOptions subcmd_options;

if (bHelp)
subcmd_options.push_back("--help");
Expand Down

0 comments on commit ebcadb6

Please sign in to comment.