mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-25 21:27:19 +02:00
Refactor
- Prepared CmdCustom for new command line processing code.
This commit is contained in:
parent
a3912d9123
commit
e19f087931
5 changed files with 60 additions and 20 deletions
|
@ -257,6 +257,12 @@ bool Arguments::extract_command (
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// TODO
|
||||||
|
void Arguments::remove_command (const std::string& command)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// TODO
|
// TODO
|
||||||
void Arguments::extract_filter ()
|
void Arguments::extract_filter ()
|
||||||
|
|
|
@ -49,6 +49,13 @@ public:
|
||||||
std::string combine ();
|
std::string combine ();
|
||||||
|
|
||||||
bool extract_command (const std::vector <std::string>&, std::string&);
|
bool extract_command (const std::vector <std::string>&, std::string&);
|
||||||
|
void remove_command (const std::string&);
|
||||||
|
|
||||||
|
/*
|
||||||
|
void extract_read_only (command, filter);
|
||||||
|
void extract_write_commands (filter, command, mods);
|
||||||
|
*/
|
||||||
|
|
||||||
void extract_filter ();
|
void extract_filter ();
|
||||||
void extract_modifications ();
|
void extract_modifications ();
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ Context::Context ()
|
||||||
, use_color (true)
|
, use_color (true)
|
||||||
, verbosity_legacy (false)
|
, verbosity_legacy (false)
|
||||||
, inShadow (false)
|
, inShadow (false)
|
||||||
|
, command ("")
|
||||||
, terminal_width (0)
|
, terminal_width (0)
|
||||||
, terminal_height (0)
|
, terminal_height (0)
|
||||||
{
|
{
|
||||||
|
@ -128,6 +129,15 @@ void Context::initialize (int argc, const char** argv)
|
||||||
|
|
||||||
// TODO Instantiate extension command objects.
|
// TODO Instantiate extension command objects.
|
||||||
// TODO Instantiate default command object.
|
// TODO Instantiate default command object.
|
||||||
|
|
||||||
|
// Create list of all command keywords.
|
||||||
|
std::vector <std::string> keywords;
|
||||||
|
std::map <std::string, Command*>::iterator i;
|
||||||
|
for (i = commands.begin (); i != commands.end (); ++i)
|
||||||
|
keywords.push_back (i->first);
|
||||||
|
|
||||||
|
args.extract_command (keywords, command);
|
||||||
|
|
||||||
// TODO Instantiate extension UDA objects.
|
// TODO Instantiate extension UDA objects.
|
||||||
// TODO Instantiate extension format objects.
|
// TODO Instantiate extension format objects.
|
||||||
|
|
||||||
|
@ -207,18 +217,11 @@ int Context::dispatch (std::string &out)
|
||||||
{
|
{
|
||||||
Timer t ("Context::dispatch");
|
Timer t ("Context::dispatch");
|
||||||
|
|
||||||
updateXtermTitle ();
|
|
||||||
|
|
||||||
// Create list of all command keywords.
|
|
||||||
std::vector <std::string> keywords;
|
|
||||||
std::map <std::string, Command*>::iterator i;
|
|
||||||
for (i = commands.begin (); i != commands.end (); ++i)
|
|
||||||
keywords.push_back (i->first);
|
|
||||||
|
|
||||||
// Autocomplete args against keywords.
|
// Autocomplete args against keywords.
|
||||||
std::string command;
|
if (command != "")
|
||||||
if (args.extract_command (keywords, command))
|
|
||||||
{
|
{
|
||||||
|
updateXtermTitle ();
|
||||||
|
|
||||||
Command* c = commands[command];
|
Command* c = commands[command];
|
||||||
|
|
||||||
// GC is invoked prior to running any command that displays task IDs.
|
// GC is invoked prior to running any command that displays task IDs.
|
||||||
|
@ -838,7 +841,7 @@ void Context::updateXtermTitle ()
|
||||||
{
|
{
|
||||||
std::string title;
|
std::string title;
|
||||||
join (title, " ", args);
|
join (title, " ", args);
|
||||||
std::cout << "]0;task " << title << "" << std::endl;
|
std::cout << "]0;task " << command << " " << title << "" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,18 +96,18 @@ public:
|
||||||
Directory extension_dir;
|
Directory extension_dir;
|
||||||
Config config;
|
Config config;
|
||||||
|
|
||||||
Filter filter;
|
Filter filter; // TODO Obsolete
|
||||||
Sequence sequence;
|
Sequence sequence; // TODO Obsolete
|
||||||
Subst subst;
|
Subst subst; // TODO Obsolete
|
||||||
Task task;
|
Task task; // TODO Obsolete
|
||||||
TDB tdb; // TODO Obsolete
|
TDB tdb; // TODO Obsolete
|
||||||
TDB2 tdb2;
|
TDB2 tdb2;
|
||||||
std::string commandLine;
|
std::string commandLine; // TODO Obsolete
|
||||||
std::string file_override;
|
std::string file_override;
|
||||||
std::string var_overrides;
|
std::string var_overrides;
|
||||||
std::map <std::string, std::string> aliases;
|
std::map <std::string, std::string> aliases;
|
||||||
std::vector <std::string> tagAdditions;
|
std::vector <std::string> tagAdditions; // TODO Obsolete
|
||||||
std::vector <std::string> tagRemovals;
|
std::vector <std::string> tagRemovals; // TODO Obsolete
|
||||||
Hooks hooks;
|
Hooks hooks;
|
||||||
DOM dom;
|
DOM dom;
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ public:
|
||||||
bool inShadow;
|
bool inShadow;
|
||||||
|
|
||||||
std::map <std::string, Command*> commands;
|
std::map <std::string, Command*> commands;
|
||||||
|
std::string command;
|
||||||
|
|
||||||
int terminal_width;
|
int terminal_width;
|
||||||
int terminal_height;
|
int terminal_height;
|
||||||
|
|
|
@ -81,11 +81,13 @@ int CmdCustom::execute (const std::string&, std::string& output)
|
||||||
split (sortOrder, reportSort, ',');
|
split (sortOrder, reportSort, ',');
|
||||||
validateSortColumns (sortOrder);
|
validateSortColumns (sortOrder);
|
||||||
|
|
||||||
|
/*
|
||||||
// Apply rc overrides.
|
// Apply rc overrides.
|
||||||
std::vector <std::string> filterArgs;
|
std::vector <std::string> filterArgs;
|
||||||
std::vector <std::string> filteredArgs;
|
std::vector <std::string> filteredArgs;
|
||||||
split (filterArgs, reportFilter, ' ');
|
split (filterArgs, reportFilter, ' ');
|
||||||
// context.applyOverrides (filterArgs, filteredArgs);
|
// context.applyOverrides (filterArgs, filteredArgs);
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
|
@ -108,17 +110,35 @@ int CmdCustom::execute (const std::string&, std::string& output)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Get all the tasks.
|
// Load the data.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
// context.tdb.load (tasks, context.filter);
|
||||||
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter); // TODO No filter.
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
/*
|
||||||
// Filter sequence.
|
// Filter sequence.
|
||||||
if (context.sequence.size ())
|
if (context.sequence.size ())
|
||||||
context.filter.applySequence (tasks, context.sequence);
|
context.filter.applySequence (tasks, context.sequence);
|
||||||
|
*/
|
||||||
|
|
||||||
|
////////////////////////////////////
|
||||||
|
// TODO Create the filter
|
||||||
|
context.args.remove_command (_keyword);
|
||||||
|
|
||||||
|
//std::vector <std::string> filter_args;
|
||||||
|
//context.args.extract_filter (filter_args);
|
||||||
|
|
||||||
|
// TODO Apply the filter
|
||||||
|
// Filter filter (context.args);
|
||||||
|
|
||||||
|
// std::vector <Task> filtered;
|
||||||
|
// thing.eval (filtered, context.args, tasks);
|
||||||
|
////////////////////////////////////
|
||||||
|
|
||||||
// Sort the tasks.
|
// Sort the tasks.
|
||||||
std::vector <int> sequence;
|
std::vector <int> sequence;
|
||||||
|
@ -150,6 +170,7 @@ int CmdCustom::execute (const std::string&, std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
// How many lines taken up by table header?
|
// How many lines taken up by table header?
|
||||||
|
// TODO Consider rc.verbose
|
||||||
int table_header;
|
int table_header;
|
||||||
if (context.color () && context.config.getBoolean ("fontunderline"))
|
if (context.color () && context.config.getBoolean ("fontunderline"))
|
||||||
table_header = 1; // Underlining doesn't use extra line.
|
table_header = 1; // Underlining doesn't use extra line.
|
||||||
|
@ -162,6 +183,7 @@ int CmdCustom::execute (const std::string&, std::string& output)
|
||||||
getLimits (_keyword, maxrows, maxlines);
|
getLimits (_keyword, maxrows, maxlines);
|
||||||
|
|
||||||
// Adjust for fluff in the output.
|
// Adjust for fluff in the output.
|
||||||
|
// TODO Consider rc.verbose
|
||||||
if (maxlines)
|
if (maxlines)
|
||||||
maxlines -= (context.verbose ("blank") ? 1 : 0)
|
maxlines -= (context.verbose ("blank") ? 1 : 0)
|
||||||
+ table_header
|
+ table_header
|
||||||
|
@ -169,6 +191,7 @@ int CmdCustom::execute (const std::string&, std::string& output)
|
||||||
+ context.footnotes.size ();
|
+ context.footnotes.size ();
|
||||||
|
|
||||||
// Render.
|
// Render.
|
||||||
|
// TODO Consider rc.verbose
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
if (tasks.size ())
|
if (tasks.size ())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue