- ::onExit now indicates whether changes were made.
This commit is contained in:
Paul Beckingham
2014-08-09 21:06:16 -04:00
parent 3136fa1746
commit 4ef189d7b6
2 changed files with 7 additions and 2 deletions

View File

@@ -134,10 +134,13 @@ void Hooks::onLaunch ()
// Exit: // Exit:
// 0 Means: - all emitted non-JSON lines become footnote entries // 0 Means: - all emitted non-JSON lines become footnote entries
// 1 Means: - all emitted non-JSON lines become error entries // 1 Means: - all emitted non-JSON lines become error entries
void Hooks::onExit () bool Hooks::onExit ()
{ {
context.timer_hooks.start (); context.timer_hooks.start ();
// Status indicates whether hooks resulted in new/modified tasks.
bool status = false;
std::vector <std::string> matchingScripts = scripts ("on-exit"); std::vector <std::string> matchingScripts = scripts ("on-exit");
std::vector <std::string>::iterator i; std::vector <std::string>::iterator i;
for (i = matchingScripts.begin (); i != matchingScripts.end (); ++i) for (i = matchingScripts.begin (); i != matchingScripts.end (); ++i)
@@ -157,6 +160,7 @@ void Hooks::onExit ()
{ {
Task newTask (*line); Task newTask (*line);
context.tdb2.add (newTask); context.tdb2.add (newTask);
status = true;
} }
else else
context.footnote (*line); context.footnote (*line);
@@ -173,6 +177,7 @@ void Hooks::onExit ()
} }
context.timer_hooks.stop (); context.timer_hooks.stop ();
return status;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@@ -41,7 +41,7 @@ public:
void initialize (); void initialize ();
void onLaunch (); void onLaunch ();
void onExit (); bool onExit ();
void onAdd (Task&); void onAdd (Task&);
void onModify (const Task&, Task&); void onModify (const Task&, Task&);