From 4ef189d7b63e4e7fd595cd859f065be042ae5f5b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 9 Aug 2014 21:06:16 -0400 Subject: [PATCH] Hooks - ::onExit now indicates whether changes were made. --- src/Hooks.cpp | 7 ++++++- src/Hooks.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 1a757b7d2..e2f5c09dc 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -134,10 +134,13 @@ void Hooks::onLaunch () // Exit: // 0 Means: - all emitted non-JSON lines become footnote entries // 1 Means: - all emitted non-JSON lines become error entries -void Hooks::onExit () +bool Hooks::onExit () { context.timer_hooks.start (); + // Status indicates whether hooks resulted in new/modified tasks. + bool status = false; + std::vector matchingScripts = scripts ("on-exit"); std::vector ::iterator i; for (i = matchingScripts.begin (); i != matchingScripts.end (); ++i) @@ -157,6 +160,7 @@ void Hooks::onExit () { Task newTask (*line); context.tdb2.add (newTask); + status = true; } else context.footnote (*line); @@ -173,6 +177,7 @@ void Hooks::onExit () } context.timer_hooks.stop (); + return status; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Hooks.h b/src/Hooks.h index c461cb4bf..69dbfe1f8 100644 --- a/src/Hooks.h +++ b/src/Hooks.h @@ -41,7 +41,7 @@ public: void initialize (); void onLaunch (); - void onExit (); + bool onExit (); void onAdd (Task&); void onModify (const Task&, Task&);