Enhancements - Cmd object
- New Cmd object to handle localized commands, customReports and general command parsing. - Localized new Subst methods. - Relocate guess method from parse.cpp to text.cpp. - Converted Att object to use new valid/parse scheme. - Unit tests for Cmd object. - Fixed att.t.cpp unit tests.
This commit is contained in:
@@ -158,38 +158,6 @@ static const char* commands[] =
|
||||
|
||||
static std::vector <std::string> customReports;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void guess (
|
||||
const std::string& type,
|
||||
std::vector<std::string>& options,
|
||||
std::string& candidate)
|
||||
{
|
||||
std::vector <std::string> matches;
|
||||
autoComplete (candidate, options, matches);
|
||||
if (1 == matches.size ())
|
||||
candidate = matches[0];
|
||||
|
||||
else if (0 == matches.size ())
|
||||
candidate = "";
|
||||
|
||||
else
|
||||
{
|
||||
std::string error = "Ambiguous ";
|
||||
error += type;
|
||||
error += " '";
|
||||
error += candidate;
|
||||
error += "' - could be either of ";
|
||||
for (size_t i = 0; i < matches.size (); ++i)
|
||||
{
|
||||
if (i)
|
||||
error += ", ";
|
||||
error += matches[i];
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void guess (
|
||||
const std::string& type,
|
||||
@@ -375,7 +343,7 @@ bool validDescription (const std::string& input)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static bool validCommand (std::string& input)
|
||||
bool validCommand (std::string& input)
|
||||
{
|
||||
std::string copy = input;
|
||||
guess ("command", commands, copy);
|
||||
|
||||
Reference in New Issue
Block a user