- Integrated new CLI object.
- Provided aliases and entities to CLI.
This commit is contained in:
Paul Beckingham 2014-10-13 23:17:59 -04:00
parent 3b0606922f
commit df54b8ee43
2 changed files with 25 additions and 0 deletions

View file

@ -171,35 +171,55 @@ int Context::initialize (int argc, const char** argv)
for (cmd = commands.begin (); cmd != commands.end (); ++cmd) for (cmd = commands.begin (); cmd != commands.end (); ++cmd)
{ {
parser.entity ("cmd", cmd->first); parser.entity ("cmd", cmd->first);
cli.entity ("cmd", cmd->first);
if (cmd->first[0] == '_') if (cmd->first[0] == '_')
{
parser.entity ("helper", cmd->first); parser.entity ("helper", cmd->first);
cli.entity ("helper", cmd->first);
}
if (cmd->second->read_only ()) if (cmd->second->read_only ())
{
parser.entity ("readcmd", cmd->first); parser.entity ("readcmd", cmd->first);
cli.entity ("readcmd", cmd->first);
}
else else
{
parser.entity ("writecmd", cmd->first); parser.entity ("writecmd", cmd->first);
cli.entity ("writecmd", cmd->first);
}
} }
// Instantiate built-in column objects. // Instantiate built-in column objects.
Column::factory (columns); Column::factory (columns);
std::map <std::string, Column*>::iterator col; std::map <std::string, Column*>::iterator col;
for (col = columns.begin (); col != columns.end (); ++col) for (col = columns.begin (); col != columns.end (); ++col)
{
parser.entity ("attribute", col->first); parser.entity ("attribute", col->first);
cli.entity ("attribute", col->first);
}
// Entities: Pseudo-attributes. Hard-coded. // Entities: Pseudo-attributes. Hard-coded.
parser.entity ("pseudo", "limit"); parser.entity ("pseudo", "limit");
cli.entity ("pseudo", "limit");
// Entities: Modifiers. // Entities: Modifiers.
for (unsigned int i = 0; i < NUM_MODIFIER_NAMES; ++i) for (unsigned int i = 0; i < NUM_MODIFIER_NAMES; ++i)
{
parser.entity ("modifier", modifierNames[i]); parser.entity ("modifier", modifierNames[i]);
cli.entity ("modifier", modifierNames[i]);
}
// Entities: Operators. // Entities: Operators.
std::vector <std::string> operators; std::vector <std::string> operators;
Eval::getOperators (operators); Eval::getOperators (operators);
std::vector <std::string>::iterator op; std::vector <std::string>::iterator op;
for (op = operators.begin (); op != operators.end (); ++op) for (op = operators.begin (); op != operators.end (); ++op)
{
parser.entity ("operator", *op); parser.entity ("operator", *op);
cli.entity ("operator", *op);
}
// Now the entities are loaded, parsing may resume. // Now the entities are loaded, parsing may resume.
parser.findBinary (); // <task|tw|t|cal|calendar> parser.findBinary (); // <task|tw|t|cal|calendar>
@ -752,7 +772,10 @@ void Context::loadAliases ()
std::map <std::string, std::string>::iterator i; std::map <std::string, std::string>::iterator i;
for (i = config.begin (); i != config.end (); ++i) for (i = config.begin (); i != config.end (); ++i)
if (i->first.substr (0, 6) == "alias.") if (i->first.substr (0, 6) == "alias.")
{
parser.alias (i->first.substr (6), i->second); parser.alias (i->first.substr (6), i->second);
cli.alias (i->first.substr (6), i->second);
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -38,6 +38,7 @@
#include <File.h> #include <File.h>
#include <Directory.h> #include <Directory.h>
#include <Parser.h> #include <Parser.h>
#include <CLI.h>
#include <Timer.h> #include <Timer.h>
class Context class Context
@ -84,6 +85,7 @@ private:
public: public:
std::string program; std::string program;
Parser parser; Parser parser;
CLI cli;
std::string home_dir; std::string home_dir;
File rc_file; File rc_file;
Path data_dir; Path data_dir;