Leave unrecognised (long) options in argument list.
This commit is contained in:
parent
2bdda5d4a3
commit
0468b599ad
@ -1750,6 +1750,9 @@ ParseResult::parse(int& argc, char**& argv)
|
||||
{
|
||||
if (m_allow_unrecognised)
|
||||
{
|
||||
// keep unrecognised options in argument list, skip to next argument
|
||||
argv[nextKeep] = argv[current];
|
||||
++nextKeep;
|
||||
++current;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -483,9 +483,10 @@ TEST_CASE("Unrecognised options", "[options]") {
|
||||
|
||||
Argv av({
|
||||
"unknown_options",
|
||||
"--unknown",
|
||||
"--long",
|
||||
"-su",
|
||||
"--unknown",
|
||||
"--another_unknown",
|
||||
});
|
||||
|
||||
char** argv = av.argv();
|
||||
@ -498,5 +499,7 @@ TEST_CASE("Unrecognised options", "[options]") {
|
||||
SECTION("After allowing unrecognised options") {
|
||||
options.allow_unrecognised_options();
|
||||
CHECK_NOTHROW(options.parse(argc, argv));
|
||||
REQUIRE(argc == 3);
|
||||
CHECK_THAT(argv[1], Catch::Equals("--unknown"));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user