From f1a61aaeb6243253f44070260bf7e449d9da168c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 17 Aug 2014 12:10:08 -0400 Subject: [PATCH] Parser - Modified ::findCommand to use collect. --- src/Parser.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Parser.cpp b/src/Parser.cpp index e1c00617b..d0547f029 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -466,25 +466,21 @@ void Parser::resolveAliases () // autoCompletes to a valid command/report. void Parser::findCommand () { + context.debug ("Parse::findOverrides"); + std::vector nodes; + collect (nodes, false); + // There can be only one. // Scan for an existing CMD tag, to short-circuit scanning for another. - std::string command; std::vector ::iterator i; - for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) + for (i = nodes.begin (); i != nodes.end (); ++i) if ((*i)->hasTag ("CMD")) return; // 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"))) { (*i)->unTag ("?"); @@ -500,6 +496,8 @@ void Parser::findCommand () return; } } + + context.debug (_tree->dump ()); } ////////////////////////////////////////////////////////////////////////////////