Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jarro2783/cxxopts.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarryd Beck <jarro.2783@gmail.com>2021-10-21 00:06:22 +0300
committerJarryd Beck <jarro.2783@gmail.com>2021-10-21 00:06:53 +0300
commitc74846a891b3cc3bfa992d588b1295f528d43039 (patch)
tree15f9e66786e3c249a9d6d6edf3ba239661ce85a0
parenta150450486700ae28a44f0667cf83f65de2d258b (diff)
Fix short options adding into unmatchedv3.0.0
Fixes #312.
-rw-r--r--include/cxxopts.hpp1
-rw-r--r--test/options.cpp3
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"}));
}
}