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)
|
if (m_allow_unrecognised)
|
||||||
{
|
{
|
||||||
|
// keep unrecognised options in argument list, skip to next argument
|
||||||
|
argv[nextKeep] = argv[current];
|
||||||
|
++nextKeep;
|
||||||
++current;
|
++current;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -483,9 +483,10 @@ TEST_CASE("Unrecognised options", "[options]") {
|
|||||||
|
|
||||||
Argv av({
|
Argv av({
|
||||||
"unknown_options",
|
"unknown_options",
|
||||||
|
"--unknown",
|
||||||
"--long",
|
"--long",
|
||||||
"-su",
|
"-su",
|
||||||
"--unknown",
|
"--another_unknown",
|
||||||
});
|
});
|
||||||
|
|
||||||
char** argv = av.argv();
|
char** argv = av.argv();
|
||||||
@ -498,5 +499,7 @@ TEST_CASE("Unrecognised options", "[options]") {
|
|||||||
SECTION("After allowing unrecognised options") {
|
SECTION("After allowing unrecognised options") {
|
||||||
options.allow_unrecognised_options();
|
options.allow_unrecognised_options();
|
||||||
CHECK_NOTHROW(options.parse(argc, argv));
|
CHECK_NOTHROW(options.parse(argc, argv));
|
||||||
|
REQUIRE(argc == 3);
|
||||||
|
CHECK_THAT(argv[1], Catch::Equals("--unknown"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user