From c947eab83f9fb9ce931bb8743f0f05ad86ef48fb Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Wed, 30 Sep 2015 01:14:47 +0200 Subject: [PATCH] Show some readable message when being passed an unknown option. --- src/commandline.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/commandline.cpp b/src/commandline.cpp index 4d55418..64ac03e 100644 --- a/src/commandline.cpp +++ b/src/commandline.cpp @@ -37,7 +37,13 @@ namespace duck { all.add(desc).add(positional_options); po::positional_options_description pd; pd.add("input-url", 1).add("xpath", 1); - po::store(po::command_line_parser(parArgc, parArgv).options(all).positional(pd).run(), parVarMap); + try { + po::store(po::command_line_parser(parArgc, parArgv).options(all).positional(pd).run(), parVarMap); + } + catch (const po::unknown_option& err) { + throw std::invalid_argument(err.what()); + } + po::notify(parVarMap); if (parVarMap.count("help")) {