mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Hooks
- Added ::onModify. - Stubbed out functionality in all three hook methods.
This commit is contained in:
parent
ff52a2ab59
commit
2f5435c50f
2 changed files with 74 additions and 3 deletions
|
@ -67,8 +67,25 @@ void Hooks::onLaunch ()
|
|||
{
|
||||
context.timer_hooks.start ();
|
||||
|
||||
// TODO Call all launch hook scripts.
|
||||
// TODO Non-zero exit status terminates launch.
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = _scripts.begin (); i != _scripts.end (); ++i)
|
||||
{
|
||||
if (i->substr (0, 9) == "on-launch")
|
||||
{
|
||||
File script (*i);
|
||||
if (script.executable ())
|
||||
{
|
||||
// TODO Call all launch hook scripts.
|
||||
|
||||
// TODO On zero status:
|
||||
// - all stdout --> context.footnote
|
||||
|
||||
// TODO On non-zero status:
|
||||
// - all stdout --> context.error
|
||||
// - throw std::string ("Hook termination");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.timer_hooks.stop ();
|
||||
}
|
||||
|
@ -85,7 +102,60 @@ void Hooks::onExit ()
|
|||
{
|
||||
context.timer_hooks.start ();
|
||||
|
||||
// TODO Call all exit hook scripts.
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = _scripts.begin (); i != _scripts.end (); ++i)
|
||||
{
|
||||
if (i->substr (0, 7) == "on-exit")
|
||||
{
|
||||
File script (*i);
|
||||
if (script.executable ())
|
||||
{
|
||||
// TODO Call all exit hook scripts.
|
||||
|
||||
// TODO On zero status:
|
||||
// - all stdout --> context.footnote
|
||||
|
||||
// TODO On non-zero status:
|
||||
// - all stdout --> context.error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.timer_hooks.stop ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Occurs when: A task is modified, before it is committed.
|
||||
// Data fed to stdin: before JSON
|
||||
// after JSON
|
||||
// Exit code: 0: Success
|
||||
// !0: Failure
|
||||
// Output handled: 0: modified after JSON
|
||||
// context.footnote ()
|
||||
// !0: context.error ()
|
||||
void Hooks::onModify (const Task& before, const Task& after)
|
||||
{
|
||||
context.timer_hooks.start ();
|
||||
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = _scripts.begin (); i != _scripts.end (); ++i)
|
||||
{
|
||||
if (i->substr (0, 7) == "on-modify")
|
||||
{
|
||||
File script (*i);
|
||||
if (script.executable ())
|
||||
{
|
||||
// TODO Call all modify hook scripts.
|
||||
|
||||
// TODO On zero status:
|
||||
// - first line is modified JSON
|
||||
// - remaining lines --> context.footnote
|
||||
|
||||
// TODO On non-zero status:
|
||||
// - all stdout --> context.error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.timer_hooks.stop ();
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
|
||||
void onLaunch ();
|
||||
void onExit ();
|
||||
void onModify (const Task&, const Task&);
|
||||
|
||||
private:
|
||||
std::vector <std::string> _scripts;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue