Skip to content
Snippets Groups Projects
Commit 1c950d59 authored by Felix Weiglhofer's avatar Felix Weiglhofer
Browse files

algo::Options: Print help message on unknown option.

parent 96fb0d24
No related branches found
No related tags found
1 merge request!1181cbmreco: Add flag to write logs to file.
......@@ -73,11 +73,19 @@ Options::Options(int argc, char** argv)
po::variables_map vm;
po::command_line_parser parser {argc, argv};
parser.options(cmdline_options);
po::store(parser.run(), vm);
try {
auto result = parser.run();
po::store(result, vm);
}
catch (const boost::wrapexcept<po::unknown_option>& e) {
std::cerr << "Error: " << e.what() << std::endl;
std::cerr << cmdline_options << std::endl;
std::exit(EXIT_FAILURE);
}
if (vm.count("help")) {
std::cerr << cmdline_options << std::endl;
std::exit(0);
std::exit(EXIT_SUCCESS);
}
try {
......@@ -86,6 +94,6 @@ Options::Options(int argc, char** argv)
catch (const po::required_option& e) {
std::cerr << "Error: " << e.what() << std::endl;
std::cerr << cmdline_options << std::endl;
std::exit(1);
std::exit(EXIT_FAILURE);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment