mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
CLI2: Added ::handleTerminator
- CLI2::handleTerminator removes all terminator arguments it finds and downgrades all subsequent arguments to Lexer::Type::word. This simplifies all further processing.
This commit is contained in:
parent
370df8e07f
commit
2cab600674
2 changed files with 33 additions and 0 deletions
32
src/CLI2.cpp
32
src/CLI2.cpp
|
@ -393,6 +393,37 @@ void CLI2::lexArguments ()
|
|||
context.debug (dump ("CLI2::analyze lexArguments"));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CLI2::handleTerminator ()
|
||||
{
|
||||
bool changes = false;
|
||||
bool terminated = false;
|
||||
std::vector <A2> reconstructed;
|
||||
for (auto& a : _args)
|
||||
{
|
||||
if (a._lextype == Lexer::Type::separator)
|
||||
{
|
||||
terminated = true;
|
||||
changes = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (terminated)
|
||||
a._lextype = Lexer::Type::word;
|
||||
|
||||
reconstructed.push_back (a);
|
||||
}
|
||||
}
|
||||
|
||||
if (changes)
|
||||
{
|
||||
_args = reconstructed;
|
||||
|
||||
if (context.config.getInteger ("debug.parser") >= 3)
|
||||
context.debug (dump ("CLI2::analyze handleTerminator"));
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Intended to be called after ::add() to perform the final analysis.
|
||||
void CLI2::analyze ()
|
||||
|
@ -407,6 +438,7 @@ void CLI2::analyze ()
|
|||
_args.clear ();
|
||||
handleArg0 ();
|
||||
lexArguments ();
|
||||
handleTerminator ();
|
||||
|
||||
// Process _args.
|
||||
aliasExpansion ();
|
||||
|
|
|
@ -110,6 +110,7 @@ private:
|
|||
*/
|
||||
void handleArg0 ();
|
||||
void lexArguments ();
|
||||
void handleTerminator ();
|
||||
void aliasExpansion ();
|
||||
void findOverrides ();
|
||||
void findCommand ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue