CLI2: ADded ::findCommand.
This commit is contained in:
44
src/CLI2.cpp
44
src/CLI2.cpp
@@ -412,6 +412,7 @@ void CLI2::analyze ()
|
|||||||
// Process _args.
|
// Process _args.
|
||||||
aliasExpansion ();
|
aliasExpansion ();
|
||||||
findOverrides ();
|
findOverrides ();
|
||||||
|
findCommand ();
|
||||||
|
|
||||||
if (context.config.getInteger ("debug.parser") >= 3)
|
if (context.config.getInteger ("debug.parser") >= 3)
|
||||||
{
|
{
|
||||||
@@ -923,6 +924,49 @@ void CLI2::findOverrides ()
|
|||||||
context.debug (dump ("CLI2::analyze findOverrides"));
|
context.debug (dump ("CLI2::analyze 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
|
||||||
|
{
|
||||||
|
std::string canonical;
|
||||||
|
if (! foundCommand &&
|
||||||
|
canonicalize (canonical, "cmd", raw))
|
||||||
|
{
|
||||||
|
readOnly = ! exactMatch ("writecmd", canonical);
|
||||||
|
|
||||||
|
a.tag ("CMD");
|
||||||
|
a.tag (readOnly ? "READCMD" : "WRITECMD");
|
||||||
|
a.attribute ("canonical", canonical);
|
||||||
|
foundCommand = true;
|
||||||
|
changes = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changes &&
|
||||||
|
context.config.getInteger ("debug.parser") >= 3)
|
||||||
|
context.debug (dump ("CLI2::analyze findCommand"));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// TODO This method should further categorize args into whether or not they are
|
// TODO This method should further categorize args into whether or not they are
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ private:
|
|||||||
void lexArguments ();
|
void lexArguments ();
|
||||||
void aliasExpansion ();
|
void aliasExpansion ();
|
||||||
void findOverrides ();
|
void findOverrides ();
|
||||||
|
void findCommand ();
|
||||||
/*
|
/*
|
||||||
void categorize ();
|
void categorize ();
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user