diff --git a/src/CLI.cpp b/src/CLI.cpp index 554885433..64f8eebee 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -588,22 +588,24 @@ const std::string CLI::dump (const std::string& title /* = "CLI Parser" */) cons // Either the arg is appended to _original_args intact, or the lexemes are. void CLI::addArg (const std::string& arg) { + std::string raw = trim (arg); + // Do not lex these constructs. - if (isTerminator (arg) || // -- - isRCOverride (arg) || // rc: - isConfigOverride (arg) || // rc.: - isCommand (arg) || // - isTag (arg) || // [+-] - isUUIDList (arg) || // ,[uuid ...] - isUUID (arg) || // - isIDSequence (arg) || // [-][,[-] ...] - isID (arg) || // - isPattern (arg) || // ///[g] - isAttribute (arg) || // [.[~]]: - isOperator (arg)) // + if (isTerminator (raw) || // -- + isRCOverride (raw) || // rc: + isConfigOverride (raw) || // rc.: + isCommand (raw) || // + isTag (raw) || // [+-] + isUUIDList (raw) || // ,[uuid ...] + isUUID (raw) || // + isIDSequence (raw) || // [-][,[-] ...] + isID (raw) || // + isPattern (raw) || // ///[g] + isAttribute (raw) || // [.[~]]: + isOperator (raw)) // { - _original_args.push_back (arg); + _original_args.push_back (raw); } // Lex, but only use lexemes if an operator is found in there. @@ -613,7 +615,7 @@ void CLI::addArg (const std::string& arg) // otherwise no change. std::string lexeme; Lexer::Type type; - Lexer lex (arg); + Lexer lex (raw); lex.ambiguity (false); std::vector > lexemes; @@ -631,10 +633,14 @@ void CLI::addArg (const std::string& arg) foundOP) { for (l = lexemes.begin (); l != lexemes.end (); ++l) + { _original_args.push_back (l->first); + } } else - _original_args.push_back (arg); + { + _original_args.push_back (raw); + } } }