- 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)
{
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 <std::string, Column*>::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 <std::string> operators;
Eval::getOperators (operators);
std::vector <std::string>::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 (); // <task|tw|t|cal|calendar>
@ -752,7 +772,10 @@ void Context::loadAliases ()
std::map <std::string, std::string>::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);
}
}
////////////////////////////////////////////////////////////////////////////////