mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 07:04:39 +00:00
Throw exception in case of unknown argument
This commit is contained in:
parent
36bdfe4a55
commit
9e7b80034e
@ -462,10 +462,13 @@ class ArgumentParser {
|
|||||||
auto tArgument = tIterator->second;
|
auto tArgument = tIterator->second;
|
||||||
it = tArgument->consume(it, end, tCurrentArgument);
|
it = tArgument->consume(it, end, tCurrentArgument);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
throw std::runtime_error("Unknown argument");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
++it;
|
throw std::runtime_error("Unknown argument");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,5 +34,5 @@ TEST_CASE("Parse unknown optional argument", "[compound_arguments]") {
|
|||||||
.action([](const std::string& val) { return std::stoull(val); })
|
.action([](const std::string& val) { return std::stoull(val); })
|
||||||
.help("memory in MB to give the VMM when loading");
|
.help("memory in MB to give the VMM when loading");
|
||||||
|
|
||||||
bfm.parse_args({ "./test.exe", "-om" });
|
REQUIRE_THROWS(bfm.parse_args({ "./test.exe", "-om" }));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user