mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 17:07:19 +02:00
Context
- Integrated new CLI object. - Provided aliases and entities to CLI.
This commit is contained in:
parent
3b0606922f
commit
df54b8ee43
2 changed files with 25 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <File.h>
|
||||
#include <Directory.h>
|
||||
#include <Parser.h>
|
||||
#include <CLI.h>
|
||||
#include <Timer.h>
|
||||
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue