diff options
author | Jarryd Beck <jarro.2783@gmail.com> | 2021-10-21 00:06:22 +0300 |
---|---|---|
committer | Jarryd Beck <jarro.2783@gmail.com> | 2021-10-21 00:06:53 +0300 |
commit | c74846a891b3cc3bfa992d588b1295f528d43039 (patch) | |
tree | 15f9e66786e3c249a9d6d6edf3ba239661ce85a0 | |
parent | a150450486700ae28a44f0667cf83f65de2d258b (diff) |
Fix short options adding into unmatchedv3.0.0
Fixes #312.
-rw-r--r-- | include/cxxopts.hpp | 1 | ||||
-rw-r--r-- | test/options.cpp | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp index 870755a..12456a7 100644 --- a/include/cxxopts.hpp +++ b/include/cxxopts.hpp @@ -2243,6 +2243,7 @@ OptionParser::parse(int argc, const char* const* argv) { if (m_allow_unrecognised) { + unmatched.push_back(std::string("-") + s[i]); continue; } //error diff --git a/test/options.cpp b/test/options.cpp index 0e86177..610a6bc 100644 --- a/test/options.cpp +++ b/test/options.cpp @@ -656,6 +656,7 @@ TEST_CASE("Unrecognised options", "[options]") { "--long", "-su", "--another_unknown", + "-a", }); auto** argv = av.argv(); @@ -669,7 +670,7 @@ TEST_CASE("Unrecognised options", "[options]") { options.allow_unrecognised_options(); auto result = options.parse(argc, argv); auto& unmatched = result.unmatched(); - CHECK((unmatched == std::vector<std::string>{"--unknown", "--another_unknown"})); + CHECK((unmatched == std::vector<std::string>{"--unknown", "-u", "--another_unknown", "-a"})); } } |