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
47
src/CLI2.cpp
47
src/CLI2.cpp
|
@ -927,44 +927,27 @@ void CLI2::findOverrides ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CLI2::findCommand ()
|
void CLI2::findCommand ()
|
||||||
{
|
{
|
||||||
bool changes = false;
|
|
||||||
bool foundCommand = false;
|
|
||||||
bool readOnly = false;
|
|
||||||
bool terminated = false;
|
|
||||||
|
|
||||||
for (auto& a : _args)
|
for (auto& a : _args)
|
||||||
{
|
{
|
||||||
std::string raw = a.attribute ("raw");
|
|
||||||
|
|
||||||
if (a._lextype == Lexer::Type::separator)
|
if (a._lextype == Lexer::Type::separator)
|
||||||
{
|
break;
|
||||||
terminated = true;
|
|
||||||
}
|
|
||||||
else if (terminated)
|
|
||||||
{
|
|
||||||
a.tag ("WORD");
|
|
||||||
changes = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string canonical;
|
|
||||||
if (! foundCommand &&
|
|
||||||
canonicalize (canonical, "cmd", raw))
|
|
||||||
{
|
|
||||||
readOnly = ! exactMatch ("writecmd", canonical);
|
|
||||||
|
|
||||||
a.tag ("CMD");
|
std::string canonical;
|
||||||
a.tag (readOnly ? "READCMD" : "WRITECMD");
|
if (canonicalize (canonical, "cmd", a.attribute ("raw")))
|
||||||
a.attribute ("canonical", canonical);
|
{
|
||||||
foundCommand = true;
|
a.attribute ("canonical", canonical);
|
||||||
changes = true;
|
a.tag ("CMD");
|
||||||
}
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changes &&
|
|
||||||
context.config.getInteger ("debug.parser") >= 3)
|
|
||||||
context.debug (dump ("CLI2::analyze findCommand"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue