- Removed last vestiges of old hook triggers.
This commit is contained in:
Paul Beckingham
2011-04-26 23:09:40 -04:00
parent c5f71051ad
commit 63c84129f2

View File

@@ -54,9 +54,6 @@ extern Context context;
int handleAdd (std::string& outs) int handleAdd (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-add-command"))
{
std::stringstream out; std::stringstream out;
context.task.set ("uuid", uuid ()); context.task.set ("uuid", uuid ());
@@ -146,9 +143,6 @@ int handleAdd (std::string& outs)
context.tdb.unlock (); context.tdb.unlock ();
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-add-command");
}
return rc; return rc;
} }
@@ -156,9 +150,6 @@ int handleAdd (std::string& outs)
int handleLog (std::string& outs) int handleLog (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-log-command"))
{
std::stringstream out; std::stringstream out;
context.task.setStatus (Task::completed); context.task.setStatus (Task::completed);
@@ -220,9 +211,6 @@ int handleLog (std::string& outs)
context.tdb.unlock (); context.tdb.unlock ();
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-log-command");
}
return rc; return rc;
} }
@@ -230,9 +218,6 @@ int handleLog (std::string& outs)
int handleProjects (std::string& outs) int handleProjects (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-projects-command"))
{
std::stringstream out; std::stringstream out;
std::vector <Task> tasks; std::vector <Task> tasks;
@@ -330,9 +315,6 @@ int handleProjects (std::string& outs)
} }
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-projects-command");
}
return rc; return rc;
} }
@@ -370,9 +352,6 @@ int handleCompletionProjects (std::string& outs)
int handleTags (std::string& outs) int handleTags (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-tags-command"))
{
std::stringstream out; std::stringstream out;
std::vector <Task> tasks; std::vector <Task> tasks;
@@ -448,9 +427,6 @@ int handleTags (std::string& outs)
} }
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-tags-command");
}
return rc; return rc;
} }
@@ -584,8 +560,6 @@ int handleQuery (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-query-command"))
{
// Get all the tasks. // Get all the tasks.
std::vector <Task> tasks; std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking")); context.tdb.lock (context.config.getBoolean ("locking"));
@@ -617,9 +591,6 @@ int handleQuery (std::string& outs)
} }
outs += "\n"; outs += "\n";
context.hooks.trigger ("post-query-command");
}
return rc; return rc;
} }
@@ -844,23 +815,16 @@ int handleZshCompletionCommands (std::string& outs)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void handleUndo () void handleUndo ()
{
if (context.hooks.trigger ("pre-undo-command"))
{ {
context.disallowModification (); context.disallowModification ();
context.tdb.lock (context.config.getBoolean ("locking")); context.tdb.lock (context.config.getBoolean ("locking"));
context.tdb.undo (); context.tdb.undo ();
context.tdb.unlock (); context.tdb.unlock ();
context.hooks.trigger ("post-undo-command");
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void handleMerge (std::string& outs) void handleMerge (std::string& outs)
{
if (context.hooks.trigger ("pre-merge-command"))
{ {
std::string file = trim (context.task.get ("description")); std::string file = trim (context.task.get ("description"));
std::string pushfile = ""; std::string pushfile = "";
@@ -897,8 +861,6 @@ void handleMerge (std::string& outs)
std::cout << "Merge complete.\n"; std::cout << "Merge complete.\n";
context.hooks.trigger ("post-merge-command");
if (tmpfile != "") if (tmpfile != "")
remove (tmpfile.c_str ()); remove (tmpfile.c_str ());
@@ -915,14 +877,11 @@ void handleMerge (std::string& outs)
"the uri of a remote .task directory, or create a " "the uri of a remote .task directory, or create a "
"'merge.default.uri' entry in your .taskrc file."); "'merge.default.uri' entry in your .taskrc file.");
} }
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Transfers the local data (from rc.location.data) to the remote path. Because // Transfers the local data (from rc.location.data) to the remote path. Because
// this is potentially on another machine, no checking can be performed. // this is potentially on another machine, no checking can be performed.
void handlePush (std::string& outs) void handlePush (std::string& outs)
{
if (context.hooks.trigger ("pre-push-command"))
{ {
std::string file = trim (context.task.get ("description")); std::string file = trim (context.task.get ("description"));
@@ -964,20 +923,15 @@ void handlePush (std::string& outs)
} }
std::cout << "Local tasks transferred to " << uri.data << "\n"; std::cout << "Local tasks transferred to " << uri.data << "\n";
context.hooks.trigger ("post-push-command");
} }
else else
throw std::string ("No uri was specified for the push. Either specify " throw std::string ("No uri was specified for the push. Either specify "
"the uri of a remote .task directory, or create a " "the uri of a remote .task directory, or create a "
"'push.default.uri' entry in your .taskrc file."); "'push.default.uri' entry in your .taskrc file.");
} }
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void handlePull (std::string& outs) void handlePull (std::string& outs)
{
if (context.hooks.trigger ("pre-pull-command"))
{ {
std::string file = trim (context.task.get ("description")); std::string file = trim (context.task.get ("description"));
@@ -1037,23 +991,17 @@ void handlePull (std::string& outs)
} }
std::cout << "Tasks transferred from " << uri.data << "\n"; std::cout << "Tasks transferred from " << uri.data << "\n";
context.hooks.trigger ("post-pull-command");
} }
else else
throw std::string ("No uri was specified for the pull. Either specify " throw std::string ("No uri was specified for the pull. Either specify "
"the uri of a remote .task directory, or create a " "the uri of a remote .task directory, or create a "
"'pull.default.uri' entry in your .taskrc file."); "'pull.default.uri' entry in your .taskrc file.");
} }
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int handleVersion (std::string& outs) int handleVersion (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-version-command"))
{
std::stringstream out; std::stringstream out;
// Create a table for the disclaimer. // Create a table for the disclaimer.
@@ -1126,9 +1074,6 @@ int handleVersion (std::string& outs)
<< "\n"; << "\n";
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-version-command");
}
return rc; return rc;
} }
@@ -1136,9 +1081,6 @@ int handleVersion (std::string& outs)
int handleShow (std::string& outs) int handleShow (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-config-command"))
{
std::stringstream out; std::stringstream out;
// Obtain the arguments from the description. That way, things like '--' // Obtain the arguments from the description. That way, things like '--'
@@ -1418,8 +1360,6 @@ int handleShow (std::string& outs)
} }
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-config-command");
}
return rc; return rc;
} }
@@ -1427,9 +1367,6 @@ int handleShow (std::string& outs)
int handleConfig (std::string& outs) int handleConfig (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-config-command"))
{
std::stringstream out; std::stringstream out;
// Obtain the arguments from the description. That way, things like '--' // Obtain the arguments from the description. That way, things like '--'
@@ -1539,11 +1476,10 @@ int handleConfig (std::string& outs)
else else
throw std::string ("Specify the name of a config variable to modify."); throw std::string ("Specify the name of a config variable to modify.");
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-config-command");
} }
else else
throw std::string ("Specify the name of a config variable to modify."); throw std::string ("Specify the name of a config variable to modify.");
}
return rc; return rc;
} }
@@ -1551,9 +1487,6 @@ int handleConfig (std::string& outs)
int handleDelete (std::string& outs) int handleDelete (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-delete-command"))
{
std::stringstream out; std::stringstream out;
context.disallowModification (); context.disallowModification ();
@@ -1580,8 +1513,6 @@ int handleDelete (std::string& outs)
{ {
if (task->getStatus () == Task::pending || if (task->getStatus () == Task::pending ||
task->getStatus () == Task::waiting) task->getStatus () == Task::waiting)
{
if (context.hooks.trigger ("pre-delete", *task))
{ {
std::stringstream question; std::stringstream question;
question << "Permanently delete task " question << "Permanently delete task "
@@ -1674,9 +1605,6 @@ int handleDelete (std::string& outs)
out << "Task not deleted.\n"; out << "Task not deleted.\n";
rc = 1; rc = 1;
} }
context.hooks.trigger ("post-delete", *task);
}
} }
else else
{ {
@@ -1693,9 +1621,6 @@ int handleDelete (std::string& outs)
context.tdb.unlock (); context.tdb.unlock ();
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-delete-command");
}
return rc; return rc;
} }
@@ -1703,9 +1628,6 @@ int handleDelete (std::string& outs)
int handleStart (std::string& outs) int handleStart (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-start-command"))
{
std::stringstream out; std::stringstream out;
context.disallowModification (); context.disallowModification ();
@@ -1764,9 +1686,6 @@ int handleStart (std::string& outs)
context.tdb.unlock (); context.tdb.unlock ();
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-start-command");
}
return rc; return rc;
} }
@@ -1774,9 +1693,6 @@ int handleStart (std::string& outs)
int handleStop (std::string& outs) int handleStop (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-stop-command"))
{
std::stringstream out; std::stringstream out;
context.disallowModification (); context.disallowModification ();
@@ -1827,9 +1743,6 @@ int handleStop (std::string& outs)
context.tdb.unlock (); context.tdb.unlock ();
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-stop-command");
}
return rc; return rc;
} }
@@ -1837,9 +1750,6 @@ int handleStop (std::string& outs)
int handleDone (std::string& outs) int handleDone (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-done-command"))
{
int count = 0; int count = 0;
std::stringstream out; std::stringstream out;
@@ -1894,8 +1804,6 @@ int handleDone (std::string& outs)
task->validate (); task->validate ();
if (taskDiff (before, *task)) if (taskDiff (before, *task))
{
if (context.hooks.trigger ("pre-completed", *task))
{ {
if (permission.confirmed (before, taskDifferences (before, *task) + "Proceed with change?")) if (permission.confirmed (before, taskDifferences (before, *task) + "Proceed with change?"))
{ {
@@ -1912,12 +1820,8 @@ int handleDone (std::string& outs)
context.footnote (onProjectChange (*task, false)); context.footnote (onProjectChange (*task, false));
++count; ++count;
context.hooks.trigger ("post-completed", *task);
} }
} }
else
continue;
}
updateRecurrenceMask (all, *task); updateRecurrenceMask (all, *task);
if (!nagged) if (!nagged)
@@ -1947,17 +1851,12 @@ int handleDone (std::string& outs)
<< " as done.\n"; << " as done.\n";
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-done-command");
}
return rc; return rc;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int handleModify (std::string& outs) int handleModify (std::string& outs)
{ {
context.hooks.trigger ("pre-modify-command");
int count = 0; int count = 0;
std::stringstream out; std::stringstream out;
@@ -2087,7 +1986,6 @@ int handleModify (std::string& outs)
out << "Modified " << count << " task" << (count == 1 ? ".\n" : "s.\n"); out << "Modified " << count << " task" << (count == 1 ? ".\n" : "s.\n");
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-modify-command");
return 0; return 0;
} }
@@ -2095,9 +1993,6 @@ int handleModify (std::string& outs)
int handleAppend (std::string& outs) int handleAppend (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-append-command"))
{
int count = 0; int count = 0;
std::stringstream out; std::stringstream out;
@@ -2172,9 +2067,6 @@ int handleAppend (std::string& outs)
out << "Appended " << count << " task" << (count == 1 ? ".\n" : "s.\n"); out << "Appended " << count << " task" << (count == 1 ? ".\n" : "s.\n");
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-append-command");
}
return rc; return rc;
} }
@@ -2182,9 +2074,6 @@ int handleAppend (std::string& outs)
int handlePrepend (std::string& outs) int handlePrepend (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-prepend-command"))
{
int count = 0; int count = 0;
std::stringstream out; std::stringstream out;
@@ -2259,9 +2148,6 @@ int handlePrepend (std::string& outs)
out << "Prepended " << count << " task" << (count == 1 ? ".\n" : "s.\n"); out << "Prepended " << count << " task" << (count == 1 ? ".\n" : "s.\n");
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-prepend-command");
}
return rc; return rc;
} }
@@ -2269,9 +2155,6 @@ int handlePrepend (std::string& outs)
int handleDuplicate (std::string& outs) int handleDuplicate (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-duplicate-command"))
{
std::stringstream out; std::stringstream out;
int count = 0; int count = 0;
@@ -2358,9 +2241,6 @@ int handleDuplicate (std::string& outs)
context.tdb.unlock (); context.tdb.unlock ();
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-duplicate-command");
}
return rc; return rc;
} }
@@ -2369,8 +2249,6 @@ int handleCount (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-count-command"))
{
// Scan the pending tasks, applying any filter. // Scan the pending tasks, applying any filter.
std::vector <Task> tasks; std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking")); context.tdb.lock (context.config.getBoolean ("locking"));
@@ -2389,8 +2267,6 @@ int handleCount (std::string& outs)
std::stringstream out; std::stringstream out;
out << count << "\n"; out << count << "\n";
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-count-command");
}
return rc; return rc;
} }
@@ -2400,8 +2276,6 @@ int handleIds (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-ids-command"))
{
// Scan the pending tasks, applying any filter. // Scan the pending tasks, applying any filter.
std::vector <Task> tasks; std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking")); context.tdb.lock (context.config.getBoolean ("locking"));
@@ -2418,17 +2292,11 @@ int handleIds (std::string& outs)
std::sort (ids.begin (), ids.end ()); std::sort (ids.begin (), ids.end ());
outs = compressIds (ids) + "\n"; outs = compressIds (ids) + "\n";
context.hooks.trigger ("post-ids-command");
}
return rc; return rc;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void handleShell () void handleShell ()
{
if (context.hooks.trigger ("pre-shell-command"))
{ {
// Display some kind of welcome message. // Display some kind of welcome message.
Color bold (Color::nocolor, Color::nocolor, false, true, false); Color bold (Color::nocolor, Color::nocolor, false, true, false);
@@ -2454,13 +2322,7 @@ void handleShell ()
do do
{ {
std::string prompt = context.config.get ("shell.prompt"); std::cout << context.config.get ("shell.prompt") << " ";
if (context.hooks.trigger ("pre-shell-prompt"))
{
//context.hooks.trigger ("format-prompt", "prompt", prompt);
std::cout << prompt << " ";
}
context.hooks.trigger ("post-shell-prompt");
command = ""; command = "";
std::getline (std::cin, command); std::getline (std::cin, command);
@@ -2501,17 +2363,12 @@ void handleShell ()
// No need to repeat any overrides after the shell quits. // No need to repeat any overrides after the shell quits.
context.clearMessages (); context.clearMessages ();
context.hooks.trigger ("post-shell-command");
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int handleColor (std::string& outs) int handleColor (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-color-command"))
{
std::stringstream out; std::stringstream out;
if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor"))
@@ -2712,9 +2569,6 @@ int handleColor (std::string& outs)
} }
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-color-command");
}
return rc; return rc;
} }
@@ -2723,8 +2577,6 @@ int handleAnnotate (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-annotate-command"))
{
if (!context.task.has ("description")) if (!context.task.has ("description"))
throw std::string ("Cannot apply a blank annotation."); throw std::string ("Cannot apply a blank annotation.");
@@ -2778,9 +2630,6 @@ int handleAnnotate (std::string& outs)
context.tdb.unlock (); context.tdb.unlock ();
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-annotate-command");
}
return rc; return rc;
} }
@@ -2789,8 +2638,6 @@ int handleDenotate (std::string& outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-denotate-command"))
{
if (!context.task.has ("description")) if (!context.task.has ("description"))
throw std::string ("Description needed to delete an annotation."); throw std::string ("Description needed to delete an annotation.");
@@ -2882,9 +2729,6 @@ int handleDenotate (std::string& outs)
context.tdb.unlock (); context.tdb.unlock ();
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-denotate-command");
}
return rc; return rc;
} }
@@ -2935,23 +2779,15 @@ int deltaTags (Task& task)
std::vector <std::string> tags; std::vector <std::string> tags;
context.task.getTags (tags); context.task.getTags (tags);
foreach (tag, tags) foreach (tag, tags)
{
if (context.hooks.trigger ("pre-tag", task))
{ {
task.addTag (*tag); task.addTag (*tag);
++changes; ++changes;
context.hooks.trigger ("post-tag", task);
}
} }
foreach (tag, context.tagRemovals) foreach (tag, context.tagRemovals)
{
if (context.hooks.trigger ("pre-detag", task))
{ {
task.removeTag (*tag); task.removeTag (*tag);
++changes; ++changes;
context.hooks.trigger ("post-detag", task);
}
} }
return changes; return changes;