mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI2: Simplified ::findCommand
This commit is contained in:
parent
cacc427cbd
commit
d1e7537e76
1 changed files with 15 additions and 32 deletions
43
src/CLI2.cpp
43
src/CLI2.cpp
|
@ -927,44 +927,27 @@ void CLI2::findOverrides ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CLI2::findCommand ()
|
||||
{
|
||||
bool changes = false;
|
||||
bool foundCommand = false;
|
||||
bool readOnly = false;
|
||||
bool terminated = false;
|
||||
|
||||
for (auto& a : _args)
|
||||
{
|
||||
std::string raw = a.attribute ("raw");
|
||||
|
||||
if (a._lextype == Lexer::Type::separator)
|
||||
{
|
||||
terminated = true;
|
||||
}
|
||||
else if (terminated)
|
||||
{
|
||||
a.tag ("WORD");
|
||||
changes = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
|
||||
std::string canonical;
|
||||
if (! foundCommand &&
|
||||
canonicalize (canonical, "cmd", raw))
|
||||
if (canonicalize (canonical, "cmd", a.attribute ("raw")))
|
||||
{
|
||||
readOnly = ! exactMatch ("writecmd", canonical);
|
||||
|
||||
a.tag ("CMD");
|
||||
a.tag (readOnly ? "READCMD" : "WRITECMD");
|
||||
a.attribute ("canonical", canonical);
|
||||
foundCommand = true;
|
||||
changes = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
a.tag ("CMD");
|
||||
|
||||
if (changes &&
|
||||
context.config.getInteger ("debug.parser") >= 3)
|
||||
bool readOnly = ! exactMatch ("writecmd", canonical);
|
||||
a.tag (readOnly ? "READCMD" : "WRITECMD");
|
||||
|
||||
if (context.config.getInteger ("debug.parser") >= 3)
|
||||
context.debug (dump ("CLI2::analyze findCommand"));
|
||||
|
||||
// Stop at first command.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue