From df54b8ee4393fa8a7d09d8906ef7e7e588cfc054 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 13 Oct 2014 23:17:59 -0400 Subject: [PATCH] Context - Integrated new CLI object. - Provided aliases and entities to CLI. --- src/Context.cpp | 23 +++++++++++++++++++++++ src/Context.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/Context.cpp b/src/Context.cpp index 31b1ac8df..a1e294228 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -171,35 +171,55 @@ int Context::initialize (int argc, const char** argv) for (cmd = commands.begin (); cmd != commands.end (); ++cmd) { parser.entity ("cmd", cmd->first); + cli.entity ("cmd", cmd->first); if (cmd->first[0] == '_') + { parser.entity ("helper", cmd->first); + cli.entity ("helper", cmd->first); + } if (cmd->second->read_only ()) + { parser.entity ("readcmd", cmd->first); + cli.entity ("readcmd", cmd->first); + } else + { parser.entity ("writecmd", cmd->first); + cli.entity ("writecmd", cmd->first); + } } // Instantiate built-in column objects. Column::factory (columns); std::map ::iterator col; for (col = columns.begin (); col != columns.end (); ++col) + { parser.entity ("attribute", col->first); + cli.entity ("attribute", col->first); + } // Entities: Pseudo-attributes. Hard-coded. parser.entity ("pseudo", "limit"); + cli.entity ("pseudo", "limit"); // Entities: Modifiers. for (unsigned int i = 0; i < NUM_MODIFIER_NAMES; ++i) + { parser.entity ("modifier", modifierNames[i]); + cli.entity ("modifier", modifierNames[i]); + } // Entities: Operators. std::vector operators; Eval::getOperators (operators); std::vector ::iterator op; for (op = operators.begin (); op != operators.end (); ++op) + { parser.entity ("operator", *op); + cli.entity ("operator", *op); + } // Now the entities are loaded, parsing may resume. parser.findBinary (); // @@ -752,7 +772,10 @@ void Context::loadAliases () std::map ::iterator i; for (i = config.begin (); i != config.end (); ++i) if (i->first.substr (0, 6) == "alias.") + { parser.alias (i->first.substr (6), i->second); + cli.alias (i->first.substr (6), i->second); + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Context.h b/src/Context.h index f4c8ce4de..eb34f97a4 100644 --- a/src/Context.h +++ b/src/Context.h @@ -38,6 +38,7 @@ #include #include #include +#include #include class Context @@ -84,6 +85,7 @@ private: public: std::string program; Parser parser; + CLI cli; std::string home_dir; File rc_file; Path data_dir;