mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Parser
- Added exact match shortcut. - Changed order of command matching to reduce changes of the log/logo problem. - Corrected logic where an "else if" should have been an "if". - Removed commented-out diagnostics.
This commit is contained in:
parent
4ada2e2c43
commit
a4d908d8b2
1 changed files with 11 additions and 26 deletions
|
@ -180,7 +180,16 @@ bool Parser::canonicalize (
|
|||
std::vector <std::string> options;
|
||||
std::multimap <std::string, std::string>::const_iterator e;
|
||||
for (e = c.first; e != c.second; ++e)
|
||||
{
|
||||
// Shortcut: if an exact match is found, success.
|
||||
if (value == e->second)
|
||||
{
|
||||
canonicalized = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
options.push_back (e->second);
|
||||
}
|
||||
|
||||
// Match against the options, throw away results.
|
||||
std::vector <std::string> matches;
|
||||
|
@ -269,16 +278,14 @@ void Parser::findCommand ()
|
|||
if (! (*i)->hasTag ("?"))
|
||||
continue;
|
||||
|
||||
/*
|
||||
if (canonicalize (command, "report", (*i)->attribute ("raw")))
|
||||
if (canonicalize (command, "writecmd", (*i)->attribute ("raw")))
|
||||
{
|
||||
(*i)->unTag ("?");
|
||||
(*i)->tag ("CMD");
|
||||
(*i)->tag ("REPORT");
|
||||
(*i)->tag ("WRITECMD");
|
||||
(*i)->attribute ("canonical", command);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
else if (canonicalize (command, "readcmd", (*i)->attribute ("raw")))
|
||||
{
|
||||
|
@ -289,15 +296,6 @@ void Parser::findCommand ()
|
|||
break;
|
||||
}
|
||||
|
||||
else if (canonicalize (command, "writecmd", (*i)->attribute ("raw")))
|
||||
{
|
||||
(*i)->unTag ("?");
|
||||
(*i)->tag ("CMD");
|
||||
(*i)->tag ("WRITECMD");
|
||||
(*i)->attribute ("canonical", command);
|
||||
break;
|
||||
}
|
||||
|
||||
else if (canonicalize (command, "helper", (*i)->attribute ("raw")))
|
||||
{
|
||||
(*i)->unTag ("?");
|
||||
|
@ -306,17 +304,6 @@ void Parser::findCommand ()
|
|||
(*i)->attribute ("canonical", command);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
else if (canonicalize (command, "specialcmd", (*i)->attribute ("raw")))
|
||||
{
|
||||
(*i)->unTag ("?");
|
||||
(*i)->tag ("CMD");
|
||||
(*i)->tag ("SPECIALCMD");
|
||||
(*i)->attribute ("canonical", command);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1468,8 +1455,6 @@ void Parser::validate ()
|
|||
std::vector <Tree*>::iterator i;
|
||||
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
||||
if ((*i)->hasTag ("?"))
|
||||
//throw std::string ("Unrecognized argument '") + (*i)->attribute ("raw") + "'";
|
||||
//std::cout << "Unrecognized argument '" << (*i)->attribute ("raw") << "'\n";
|
||||
context.debug ("Unrecognized argument '" + (*i)->attribute ("raw") + "'");
|
||||
|
||||
// TODO Any RC node must have a root/+RC @file that exists.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue