diff --git a/src/cxxopts.cpp b/src/cxxopts.cpp index e0c31c1..a6baeec 100644 --- a/src/cxxopts.cpp +++ b/src/cxxopts.cpp @@ -154,7 +154,7 @@ Options::parse(int& argc, char**& argv) { int current = 1; - std::set consumed; + int nextKeep = 1; while (current != argc) { @@ -172,6 +172,8 @@ Options::parse(int& argc, char**& argv) } else { + argv[nextKeep] = argv[current]; + ++nextKeep; } //if we return from here then it was parsed successfully, so continue } @@ -262,6 +264,8 @@ Options::parse(int& argc, char**& argv) ++current; } + + argc = nextKeep; } } diff --git a/src/main.cpp b/src/main.cpp index 76a2753..de4fe73 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -71,6 +71,8 @@ int main(int argc, char* argv[]) << std::endl; } + std::cout << argc << std::endl; + } catch (const cxxopts::OptionException& e) { std::cout << "error parsing options: " << e.what() << std::endl;