mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-30 20:53:52 +00:00
Fix an issue where an error was generated if just a file name was supplied to the split_program_name parsing (#740)
This commit is contained in:
parent
c692be41cf
commit
020a21afc6
@ -1163,7 +1163,7 @@ inline std::pair<std::string, std::string> split_program_name(std::string comman
|
|||||||
}
|
}
|
||||||
|
|
||||||
// strip the program name
|
// strip the program name
|
||||||
vals.second = (esp != std::string::npos) ? commandline.substr(esp + 1) : std::string{};
|
vals.second = (esp < commandline.length() - 1) ? commandline.substr(esp + 1) : std::string{};
|
||||||
ltrim(vals.second);
|
ltrim(vals.second);
|
||||||
return vals;
|
return vals;
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,15 @@ TEST_CASE_METHOD(TApp, "ProgNameWithSpace", "[stringparse]") {
|
|||||||
CHECK(app.get_name() == "Foo Bar");
|
CHECK(app.get_name() == "Foo Bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// From GitHub issue #739 https://github.com/CLIUtils/CLI11/issues/739
|
||||||
|
TEST_CASE_METHOD(TApp, "ProgNameOnly", "[stringparse]") {
|
||||||
|
|
||||||
|
app.add_flag("--foo");
|
||||||
|
CHECK_NOTHROW(app.parse("\"C:\\example.exe\"", true));
|
||||||
|
|
||||||
|
CHECK(app.get_name() == "C:\\example.exe");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE_METHOD(TApp, "ProgNameWithSpaceEmbeddedQuote", "[stringparse]") {
|
TEST_CASE_METHOD(TApp, "ProgNameWithSpaceEmbeddedQuote", "[stringparse]") {
|
||||||
|
|
||||||
app.add_flag("--foo");
|
app.add_flag("--foo");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user