mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-01 11:20:19 +02:00
Enhancement - Hooks
- Implemented pre-info-command, post-info-command hook.
This commit is contained in:
parent
d6daa336ca
commit
c8d208b9be
3 changed files with 256 additions and 246 deletions
|
@ -185,7 +185,8 @@ bool Hooks::eventType (const std::string& event, std::string& type)
|
|||
event == "pre-undo" || event == "post-undo" ||
|
||||
event == "pre-file-lock" || event == "post-file-lock" ||
|
||||
event == "pre-add-command" || event == "post-add-command" ||
|
||||
event == "pre-delete-command" || event == "post-delete-command")
|
||||
event == "pre-delete-command" || event == "post-delete-command" ||
|
||||
event == "pre-info-command" || event == "post-info-command")
|
||||
{
|
||||
type = "program";
|
||||
return true;
|
||||
|
|
|
@ -52,7 +52,8 @@ extern Context context;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int handleAdd (std::string &outs)
|
||||
{
|
||||
context.hooks.trigger ("pre-add-command");
|
||||
if (context.hooks.trigger ("pre-add-command"))
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
context.task.set ("uuid", uuid ());
|
||||
|
@ -114,6 +115,8 @@ int handleAdd (std::string &outs)
|
|||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-add-command");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -300,6 +300,9 @@ int longUsage (std::string &outs)
|
|||
int handleInfo (std::string &outs)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-info-command"))
|
||||
{
|
||||
// Get all the tasks.
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
|
@ -525,6 +528,9 @@ int handleInfo (std::string &outs)
|
|||
}
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-info-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue