mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 00:43:07 +02:00
CLI2: Implement inserting modification arguments
Method to inject mods into the command, to be used by writeable context.
This commit is contained in:
parent
9128798fee
commit
5c3cf0f438
2 changed files with 37 additions and 1 deletions
37
src/CLI2.cpp
37
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)
|
void CLI2::addFilter (const std::string& arg)
|
||||||
{
|
{
|
||||||
if (arg.length ())
|
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 <std::string> 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
|
// There are situations where a context filter is applied. This method
|
||||||
// determines whether one applies, and if so, applies it. Disqualifiers include:
|
// determines whether one applies, and if so, applies it. Disqualifiers include:
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
void add (const std::vector <std::string>&, int offset = 0);
|
void add (const std::vector <std::string>&, int offset = 0);
|
||||||
void analyze ();
|
void analyze ();
|
||||||
void addFilter (const std::string& arg);
|
void addFilter (const std::string& arg);
|
||||||
|
void addModifications (const std::string& arg);
|
||||||
void addContextFilter ();
|
void addContextFilter ();
|
||||||
void prepareFilter ();
|
void prepareFilter ();
|
||||||
const std::vector <std::string> getWords ();
|
const std::vector <std::string> getWords ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue