From 3e714913a0c2ec1935f9d5027800f6b0114e2465 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Mon, 6 Jan 2020 15:28:20 +0100 Subject: [PATCH] Disallow positional arguments for (i)soltest instead of ignoring --- test/Common.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/Common.cpp b/test/Common.cpp index 48966d9a3..10a0ed3e8 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -117,9 +117,20 @@ bool CommonOptions::parse(int argc, char const* const* argv) po::command_line_parser cmdLineParser(argc, argv); cmdLineParser.options(options); - po::store(cmdLineParser.run(), arguments); + auto parsedOptions = cmdLineParser.run(); + po::store(parsedOptions, arguments); po::notify(arguments); + for (auto const& parsedOption: parsedOptions.options) + if (parsedOption.position_key >= 0) + { + std::stringstream errorMessage; + errorMessage << "Unrecognized option: "; + for (auto const& token: parsedOption.original_tokens) + errorMessage << token; + throw std::runtime_error(errorMessage.str()); + } + return true; }