mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-03 22:54:39 +00:00
Closes #56
This commit is contained in:
parent
f9ab33d1a6
commit
c707bcc1c4
@ -321,7 +321,7 @@ private:
|
||||
|
||||
// If an argument starts with "-" or "--", then it's optional
|
||||
static bool is_optional(const std::string &aName) {
|
||||
return (!aName.empty() && aName[0] == '-' && !is_integer(aName) &&
|
||||
return (aName.size() > 1 && aName[0] == '-' && !is_integer(aName) &&
|
||||
!is_float(aName));
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,13 @@ DOCTEST_TEST_CASE("Parse toggle arguments with default value [optional_arguments
|
||||
REQUIRE(program["--verbose"] == false);
|
||||
}
|
||||
|
||||
DOCTEST_TEST_CASE("Argument '-' is not an optional argument [optional_arguments]") {
|
||||
argparse::ArgumentParser program("test");
|
||||
program.add_argument("input");
|
||||
program.parse_args({ "./test.exe", "-"});
|
||||
REQUIRE(program.get<std::string>("input") == "-");
|
||||
}
|
||||
|
||||
DOCTEST_TEST_CASE("Parse toggle arguments with implicit value [optional_arguments]") {
|
||||
argparse::ArgumentParser program("test");
|
||||
program.add_argument("--verbose")
|
||||
|
Loading…
Reference in New Issue
Block a user