- Added ::onAdd.
This commit is contained in:
Paul Beckingham 2014-05-13 22:04:35 -04:00
parent 2f5435c50f
commit 631e4176c7
2 changed files with 43 additions and 7 deletions

View file

@ -125,22 +125,57 @@ void Hooks::onExit ()
}
////////////////////////////////////////////////////////////////////////////////
// Occurs when: A task is modified, before it is committed.
// Data fed to stdin: before JSON
// after JSON
// Occurs when: A task is created, before it is committed.
// Data fed to stdin: task JSON
// Exit code: 0: Success
// !0: Failure
// Output handled: 0: modified after JSON
// Output handled: 0: modified JSON
// context.footnote ()
// !0: context.error ()
void Hooks::onModify (const Task& before, const Task& after)
void Hooks::onAdd (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")
if (i->substr (0, 6) == "on-add")
{
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 ();
}
////////////////////////////////////////////////////////////////////////////////
// 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, Task& after)
{
context.timer_hooks.start ();
std::vector <std::string>::iterator i;
for (i = _scripts.begin (); i != _scripts.end (); ++i)
{
if (i->substr (0, 9) == "on-modify")
{
File script (*i);
if (script.executable ())

View file

@ -42,7 +42,8 @@ public:
void onLaunch ();
void onExit ();
void onModify (const Task&, const Task&);
void onAdd (Task&);
void onModify (const Task&, Task&);
private:
std::vector <std::string> _scripts;