diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 2482dc4db..be572bbf2 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -537,7 +537,8 @@ void CLI2::analyze () } //////////////////////////////////////////////////////////////////////////////// -// Process raw string. +// Process raw filter string. +// Insert filter arguments (wrapped in parentheses) immediatelly after the binary. void CLI2::addFilter (const std::string& arg) { if (arg.length ()) @@ -558,6 +559,40 @@ void CLI2::addFilter (const std::string& arg) } } +//////////////////////////////////////////////////////////////////////////////// +// Process raw modification string. +// Insert modification arguments immediatelly after the command (i.e. 'add') +void CLI2::addModifications (const std::string& arg) +{ + if (arg.length ()) + { + std::vector mods; + + std::string lexeme; + Lexer::Type type; + Lexer lex (arg); + + while (lex.token (lexeme, type)) + mods.push_back (lexeme); + + // Determine at which argument index does the task command reside + unsigned int cmdIndex = 0; + for (; cmdIndex < _args.size(); ++cmdIndex) + { + if (a._lextype == Lexer::Type::separator) + continue; + + // Command found, stop iterating. + if (a.hasTag ("CMD")) + break; + } + + // Insert modifications after the command. + add (mods, cmdIndex); + analyze (); + } +} + //////////////////////////////////////////////////////////////////////////////// // There are situations where a context filter is applied. This method // determines whether one applies, and if so, applies it. Disqualifiers include: diff --git a/src/CLI2.h b/src/CLI2.h index 1e46ef2cc..ce9e386b0 100644 --- a/src/CLI2.h +++ b/src/CLI2.h @@ -73,6 +73,7 @@ public: void add (const std::vector &, int offset = 0); void analyze (); void addFilter (const std::string& arg); + void addModifications (const std::string& arg); void addContextFilter (); void prepareFilter (); const std::vector getWords ();