diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 0d3d7cf96..7899e04df 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -364,6 +364,25 @@ void CLI2::add (const std::string& argument) _args.clear (); } +//////////////////////////////////////////////////////////////////////////////// +// Capture a set of arguments, inserted immediately after the binary. +void CLI2::add (const std::vector & arguments) +{ + std::vector replacement; + replacement.push_back (_original_args[0]); + + for (auto& arg : arguments) + replacement.push_back (arg); + + for (unsigned int i = 1; i < _original_args.size (); ++i) + replacement.push_back (_original_args[i]); + + _original_args = replacement; + + // Adding a new argument invalidates prior analysis. + _args.clear (); +} + //////////////////////////////////////////////////////////////////////////////// // Arg0 is the first argument, which is the name and potentially a relative or // absolute path to the invoked binary. @@ -532,19 +551,22 @@ void CLI2::analyze () // Process raw string. void CLI2::addFilter (const std::string& arg) { + std::vector filter; + if (arg.length ()) - add ("("); + filter.push_back ("("); std::string lexeme; Lexer::Type type; Lexer lex (arg); while (lex.token (lexeme, type)) - add (lexeme); + filter.push_back (lexeme); if (arg.length ()) - add (")"); + filter.push_back (")"); + add (filter); analyze (); } diff --git a/src/CLI2.h b/src/CLI2.h index 72bf2a0f1..92d04d57a 100644 --- a/src/CLI2.h +++ b/src/CLI2.h @@ -74,6 +74,7 @@ public: void entity (const std::string&, const std::string&); void add (const std::string&); + void add (const std::vector &); void analyze (); void addFilter (const std::string& arg); void addContextFilter ();