From 6e906e4dbfca2eed36af55e4b84e7e08c06bc6ae Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 9 Nov 2014 13:59:40 -0500 Subject: [PATCH] CLI - Made argument termination (--) persists across ::addArg calls. --- src/CLI.cpp | 20 +++++++++++++++----- src/CLI.h | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/CLI.cpp b/src/CLI.cpp index 868e4a7f2..4a5f412c7 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -308,6 +308,7 @@ void CLI::applyOverrides (int argc, const char** argv) //////////////////////////////////////////////////////////////////////////////// CLI::CLI () : _strict (false) +, _terminated (false) { } @@ -347,10 +348,16 @@ void CLI::initialize (int argc, const char** argv) _original_args.clear (); _id_ranges.clear (); _uuid_list.clear (); + _terminated = false; _original_args.push_back (argv[0]); + bool terminated = false; for (int i = 1; i < argc; ++i) + { + if (isTerminator (argv[i])) + _terminated = true; addArg (argv[i]); + } analyze (); } @@ -619,7 +626,10 @@ void CLI::addArg (const std::string& arg) std::string raw = trim (arg); // Do not lex these constructs. - if (isTerminator (raw) || // -- + if (isTerminator (raw)) // -- + _terminated = true; + + if (_terminated || isRCOverride (raw) || // rc: isConfigOverride (raw) || // rc.: isCommand (raw) || // @@ -660,10 +670,10 @@ void CLI::addArg (const std::string& arg) if (lexemes.size () > 2 && foundOP) { - for (l = lexemes.begin (); l != lexemes.end (); ++l) - { - _original_args.push_back (l->first); - } + for (l = lexemes.begin (); l != lexemes.end (); ++l) + { + _original_args.push_back (l->first); + } } else { diff --git a/src/CLI.h b/src/CLI.h index bae2a9625..1e461dc07 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -134,6 +134,7 @@ public: std::vector > _id_ranges; std::vector _uuid_list; bool _strict; + bool _terminated; }; #endif