mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 17:07:19 +02:00
Hooks
- Removed all obsolete hooks, except from commands.cpp, which is being worked on in parallel. - Implemented new on-launch and on-exit unit tests.
This commit is contained in:
parent
2f4efb28d6
commit
48eb4757f8
15 changed files with 2816 additions and 3246 deletions
|
@ -124,7 +124,7 @@ void Context::initialize (int argc, char** argv)
|
|||
// Hook system init, plus post-start event occurring at the first possible
|
||||
// moment after hook initialization.
|
||||
hooks.initialize ();
|
||||
hooks.trigger ("post-start");
|
||||
hooks.trigger ("on-launch");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -189,41 +189,33 @@ int Context::run ()
|
|||
}
|
||||
|
||||
// Dump all debug messages.
|
||||
hooks.trigger ("pre-debug");
|
||||
if (config.getBoolean ("debug"))
|
||||
foreach (d, debugMessages)
|
||||
if (config.getBoolean ("color") || config.getBoolean ("_forcecolor"))
|
||||
std::cout << colorizeDebug (*d) << "\n";
|
||||
else
|
||||
std::cout << *d << "\n";
|
||||
hooks.trigger ("post-debug");
|
||||
|
||||
// Dump all headers.
|
||||
hooks.trigger ("pre-header");
|
||||
if (config.getBoolean ("verbose"))
|
||||
foreach (h, headers)
|
||||
if (config.getBoolean ("color") || config.getBoolean ("_forcecolor"))
|
||||
std::cout << colorizeHeader (*h) << "\n";
|
||||
else
|
||||
std::cout << *h << "\n";
|
||||
hooks.trigger ("post-header");
|
||||
|
||||
// Dump the report output.
|
||||
hooks.trigger ("pre-output");
|
||||
std::cout << output;
|
||||
hooks.trigger ("post-output");
|
||||
|
||||
// Dump all footnotes.
|
||||
hooks.trigger ("pre-footnote");
|
||||
if (config.getBoolean ("verbose"))
|
||||
foreach (f, footnotes)
|
||||
if (config.getBoolean ("color") || config.getBoolean ("_forcecolor"))
|
||||
std::cout << colorizeFootnote (*f) << "\n";
|
||||
else
|
||||
std::cout << *f << "\n";
|
||||
hooks.trigger ("post-footnote");
|
||||
|
||||
hooks.trigger ("pre-exit");
|
||||
hooks.trigger ("on-exit");
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -234,8 +226,6 @@ int Context::dispatch (std::string &out)
|
|||
|
||||
Timer t ("Context::dispatch");
|
||||
|
||||
hooks.trigger ("pre-dispatch");
|
||||
|
||||
// For read-only commands, optionally update the xterm window title.
|
||||
// Why just the read-only commands? Because this capability is to answer the
|
||||
// question of 'what did I just do to generate this outout?'.
|
||||
|
@ -310,15 +300,12 @@ int Context::dispatch (std::string &out)
|
|||
rc = handleCustomReport (cmd.command, out); }
|
||||
|
||||
// If the command is not recognized, display usage.
|
||||
else { hooks.trigger ("pre-usage-command");
|
||||
rc = shortUsage (out);
|
||||
hooks.trigger ("post-usage-command"); }
|
||||
else { rc = shortUsage (out); }
|
||||
|
||||
// Only update the shadow file if such an update was not suppressed (shadow),
|
||||
if (cmd.isWriteCommand () && !inShadow)
|
||||
shadow ();
|
||||
|
||||
hooks.trigger ("post-dispatch");
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue