CLI2: Eliminated CLI

- This is a large commit, as all the changes are centered around the elimination
  of CLI.
- CLI is no longer compiled.
- Context no longer maintains CLI + CLI2.
- Filter now walks the parse tree and sends to Eval a
  std::vector <std::pair <std::string, Lexer::Type>> containing only args tagged
  with FILTER.
- Filter more efficiently sets/unsets Eval::debug, by doing it less often.
- The filterExpr.length() check is no longer meaningful, and instead the size of
  the std::vector above is used.
- Filter::pendingOnly performs better analysis.
- Filter::safety makes use of the std::vector size also.
- Task::modify makes use of 'canonical' rather than 'name', which is a policy
  change, not a fix.
This commit is contained in:
Paul Beckingham 2015-06-24 13:12:24 -04:00
parent 183550a190
commit 737cb23546
7 changed files with 61 additions and 96 deletions

View file

@ -160,12 +160,6 @@ int Context::initialize (int argc, const char** argv)
if (cmd.first[0] == '_')
cli2.entity ("helper", cmd.first);
cli.entity ("cmd", cmd.first);
cli.entity ((cmd.second->read_only () ? "readcmd" : "writecmd"), cmd.first);
if (cmd.first[0] == '_')
cli.entity ("helper", cmd.first);
}
////////////////////////////////////////////////////////////////////////////
@ -180,11 +174,6 @@ int Context::initialize (int argc, const char** argv)
cli2.entity ("pseudo", "limit");
for (auto& col : columns)
cli.entity ("attribute", col.first);
cli.entity ("pseudo", "limit");
////////////////////////////////////////////////////////////////////////////
//
// [5] Capture modifier and operator entities.
@ -200,15 +189,6 @@ int Context::initialize (int argc, const char** argv)
for (auto& op : Eval::getBinaryOperators ())
cli2.entity ("binary_operator", op);
for (unsigned int i = 0; i < NUM_MODIFIER_NAMES; ++i)
cli.entity ("modifier", modifierNames[i]);
for (auto& op : Eval::getOperators ())
cli.entity ("operator", op);
for (auto& op : Eval::getBinaryOperators ())
cli.entity ("binary_operator", op);
////////////////////////////////////////////////////////////////////////////
//
// [6] Complete the Context initialization.
@ -230,14 +210,12 @@ int Context::initialize (int argc, const char** argv)
cli2.add (argv[i]);
cli2.analyze ();
cli.initialize (argc, argv);
cli.analyze (true, true);
// Extract a recomposed command line.
bool foundDefault = false;
bool foundAssumed = false;
std::string combined;
for (auto& a : cli._args)
for (auto& a : cli2._args)
{
if (combined.length ())
combined += ' ';
@ -445,7 +423,7 @@ int Context::run ()
int Context::dispatch (std::string &out)
{
// Autocomplete args against keywords.
std::string command = cli.getCommand ();
std::string command = cli2.getCommand ();
if (command != "")
{
updateXtermTitle ();
@ -473,6 +451,10 @@ int Context::dispatch (std::string &out)
throw std::string ("");
*/
// This is something that is only needed for write commands with no other
// filter processing.
cli2.prepareFilter ();
return c->execute (out);
}
@ -644,7 +626,6 @@ void Context::getLimits (int& rows, int& lines)
// easier, it has been decoupled from Context.
void Context::staticInitialization ()
{
CLI::minimumMatchLength = config.getInteger ("abbreviation.minimum");
CLI2::minimumMatchLength = config.getInteger ("abbreviation.minimum");
Task::defaultProject = config.get ("default.project");
@ -755,9 +736,9 @@ void Context::updateXtermTitle ()
std::string command = cli2.getCommand ();
std::string title;
for (auto a = cli._args.begin (); a != cli._args.end (); ++a)
for (auto a = cli2._args.begin (); a != cli2._args.end (); ++a)
{
if (a != cli._args.begin ())
if (a != cli2._args.begin ())
title += ' ';
title += a->attribute ("raw");
@ -785,10 +766,6 @@ void Context::loadAliases ()
for (auto& i : config)
if (i.first.substr (0, 6) == "alias.")
cli2.alias (i.first.substr (6), i.second);
for (auto& i : config)
if (i.first.substr (0, 6) == "alias.")
cli.alias (i.first.substr (6), i.second);
}
////////////////////////////////////////////////////////////////////////////////