Parser
- Modified ::findCommand to use collect.
This commit is contained in:
@@ -466,25 +466,21 @@ void Parser::resolveAliases ()
|
|||||||
// autoCompletes to a valid command/report.
|
// autoCompletes to a valid command/report.
|
||||||
void Parser::findCommand ()
|
void Parser::findCommand ()
|
||||||
{
|
{
|
||||||
|
context.debug ("Parse::findOverrides");
|
||||||
|
std::vector <Tree*> nodes;
|
||||||
|
collect (nodes, false);
|
||||||
|
|
||||||
// There can be only one.
|
// There can be only one.
|
||||||
// Scan for an existing CMD tag, to short-circuit scanning for another.
|
// Scan for an existing CMD tag, to short-circuit scanning for another.
|
||||||
std::string command;
|
|
||||||
std::vector <Tree*>::iterator i;
|
std::vector <Tree*>::iterator i;
|
||||||
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
for (i = nodes.begin (); i != nodes.end (); ++i)
|
||||||
if ((*i)->hasTag ("CMD"))
|
if ((*i)->hasTag ("CMD"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// No CMD tag found, now look for a command.
|
// No CMD tag found, now look for a command.
|
||||||
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
std::string command;
|
||||||
|
for (i = nodes.begin (); i != nodes.end (); ++i)
|
||||||
{
|
{
|
||||||
// Parser override operator.
|
|
||||||
if ((*i)->attribute ("raw") == "--")
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Skip known args.
|
|
||||||
if (! (*i)->hasTag ("?"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (canonicalize (command, "cmd", (*i)->attribute ("raw")))
|
if (canonicalize (command, "cmd", (*i)->attribute ("raw")))
|
||||||
{
|
{
|
||||||
(*i)->unTag ("?");
|
(*i)->unTag ("?");
|
||||||
@@ -500,6 +496,8 @@ void Parser::findCommand ()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.debug (_tree->dump ());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user