mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +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;
|
||||
}
|
||||
|
||||
|
|
245
src/Hooks.cpp
245
src/Hooks.cpp
|
@ -73,208 +73,19 @@ Hook& Hook::operator= (const Hook& other)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
Hooks::Hooks ()
|
||||
{
|
||||
/*
|
||||
// New 2.x hooks.
|
||||
validTaskEvents.push_back ("on-task-add");
|
||||
validTaskEvents.push_back ("on-task-modify");
|
||||
validTaskEvents.push_back ("on-task-complete");
|
||||
validTaskEvents.push_back ("on-task-delete");
|
||||
validTaskEvents.push_back ("on-task-add"); // Unimplemented
|
||||
validTaskEvents.push_back ("on-task-modify"); // Unimplemented
|
||||
validTaskEvents.push_back ("on-task-complete"); // Unimplemented
|
||||
validTaskEvents.push_back ("on-task-delete"); // Unimplemented
|
||||
|
||||
validProgramEvents.push_back ("on-launch");
|
||||
validProgramEvents.push_back ("on-exit");
|
||||
validProgramEvents.push_back ("on-file-read");
|
||||
validProgramEvents.push_back ("on-file-write");
|
||||
validProgramEvents.push_back ("on-synch");
|
||||
validProgramEvents.push_back ("on-gc");
|
||||
*/
|
||||
|
||||
// Obsolete 1.x hooks.
|
||||
validProgramEvents.push_back ("post-start");
|
||||
validProgramEvents.push_back ("pre-exit");
|
||||
validProgramEvents.push_back ("pre-file-read");
|
||||
validProgramEvents.push_back ("post-file-read");
|
||||
validProgramEvents.push_back ("pre-file-write");
|
||||
validProgramEvents.push_back ("post-file-write");
|
||||
validProgramEvents.push_back ("pre-gc");
|
||||
validProgramEvents.push_back ("post-gc");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
validProgramEvents.push_back ("post-commit");
|
||||
validProgramEvents.push_back ("pre-fatal-error");
|
||||
validProgramEvents.push_back ("pre-command-line");
|
||||
validProgramEvents.push_back ("post-command-line");
|
||||
validProgramEvents.push_back ("pre-command-line-override");
|
||||
validProgramEvents.push_back ("post-command-line-override");
|
||||
validProgramEvents.push_back ("pre-config-create");
|
||||
validProgramEvents.push_back ("post-config-create");
|
||||
validProgramEvents.push_back ("pre-config-read");
|
||||
validProgramEvents.push_back ("post-config-read");
|
||||
validProgramEvents.push_back ("pre-config-value-read");
|
||||
validProgramEvents.push_back ("post-config-value-read");
|
||||
validProgramEvents.push_back ("pre-config-value-write");
|
||||
validProgramEvents.push_back ("post-config-value-write");
|
||||
validProgramEvents.push_back ("pre-file-lock");
|
||||
validProgramEvents.push_back ("post-file-lock");
|
||||
validProgramEvents.push_back ("pre-file-unlock");
|
||||
validProgramEvents.push_back ("post-file-unlock");
|
||||
validProgramEvents.push_back ("pre-output");
|
||||
validProgramEvents.push_back ("post-output");
|
||||
validProgramEvents.push_back ("pre-debug");
|
||||
validProgramEvents.push_back ("post-debug");
|
||||
validProgramEvents.push_back ("pre-header");
|
||||
validProgramEvents.push_back ("post-header");
|
||||
validProgramEvents.push_back ("pre-footnote");
|
||||
validProgramEvents.push_back ("post-footnote");
|
||||
validProgramEvents.push_back ("pre-dispatch");
|
||||
validProgramEvents.push_back ("post-dispatch");
|
||||
validProgramEvents.push_back ("pre-archive");
|
||||
validProgramEvents.push_back ("post-archive");
|
||||
validProgramEvents.push_back ("pre-purge");
|
||||
validProgramEvents.push_back ("post-purge");
|
||||
validProgramEvents.push_back ("pre-recurrence");
|
||||
validProgramEvents.push_back ("post-recurrence");
|
||||
validProgramEvents.push_back ("pre-interactive");
|
||||
validProgramEvents.push_back ("post-interactive");
|
||||
validProgramEvents.push_back ("pre-undo");
|
||||
validProgramEvents.push_back ("post-undo");
|
||||
validProgramEvents.push_back ("pre-confirm");
|
||||
validProgramEvents.push_back ("post-confirm");
|
||||
validProgramEvents.push_back ("pre-shell-prompt");
|
||||
validProgramEvents.push_back ("post-shell-prompt");
|
||||
validProgramEvents.push_back ("pre-add-command");
|
||||
validProgramEvents.push_back ("post-add-command");
|
||||
validProgramEvents.push_back ("pre-annotate-command");
|
||||
validProgramEvents.push_back ("post-annotate-command");
|
||||
validProgramEvents.push_back ("pre-denotate-command");
|
||||
validProgramEvents.push_back ("post-denotate-command");
|
||||
validProgramEvents.push_back ("pre-append-command");
|
||||
validProgramEvents.push_back ("post-append-command");
|
||||
validProgramEvents.push_back ("pre-calendar-command");
|
||||
validProgramEvents.push_back ("post-calendar-command");
|
||||
validProgramEvents.push_back ("pre-color-command");
|
||||
validProgramEvents.push_back ("post-color-command");
|
||||
validProgramEvents.push_back ("pre-config-command");
|
||||
validProgramEvents.push_back ("post-config-command");
|
||||
validProgramEvents.push_back ("pre-custom-report-command");
|
||||
validProgramEvents.push_back ("post-custom-report-command");
|
||||
validProgramEvents.push_back ("pre-default-command");
|
||||
validProgramEvents.push_back ("post-default-command");
|
||||
validProgramEvents.push_back ("pre-delete-command");
|
||||
validProgramEvents.push_back ("post-delete-command");
|
||||
validProgramEvents.push_back ("pre-done-command");
|
||||
validProgramEvents.push_back ("post-done-command");
|
||||
validProgramEvents.push_back ("pre-duplicate-command");
|
||||
validProgramEvents.push_back ("post-duplicate-command");
|
||||
validProgramEvents.push_back ("pre-count-command");
|
||||
validProgramEvents.push_back ("post-count-command");
|
||||
validProgramEvents.push_back ("pre-edit-command");
|
||||
validProgramEvents.push_back ("post-edit-command");
|
||||
validProgramEvents.push_back ("pre-export-command");
|
||||
validProgramEvents.push_back ("post-export-command");
|
||||
validProgramEvents.push_back ("pre-ghistory-command");
|
||||
validProgramEvents.push_back ("post-ghistory-command");
|
||||
validProgramEvents.push_back ("pre-history-command");
|
||||
validProgramEvents.push_back ("post-history-command");
|
||||
validProgramEvents.push_back ("pre-burndown-command");
|
||||
validProgramEvents.push_back ("post-burndown-command");
|
||||
validProgramEvents.push_back ("pre-import-command");
|
||||
validProgramEvents.push_back ("post-import-command");
|
||||
validProgramEvents.push_back ("pre-info-command");
|
||||
validProgramEvents.push_back ("post-info-command");
|
||||
validProgramEvents.push_back ("pre-merge-command");
|
||||
validProgramEvents.push_back ("post-merge-command");
|
||||
validProgramEvents.push_back ("pre-modify-command");
|
||||
validProgramEvents.push_back ("post-modify-command");
|
||||
validProgramEvents.push_back ("pre-prepend-command");
|
||||
validProgramEvents.push_back ("post-prepend-command");
|
||||
validProgramEvents.push_back ("pre-projects-command");
|
||||
validProgramEvents.push_back ("post-projects-command");
|
||||
validProgramEvents.push_back ("pre-pull-command");
|
||||
validProgramEvents.push_back ("post-pull-command");
|
||||
validProgramEvents.push_back ("pre-push-command");
|
||||
validProgramEvents.push_back ("post-push-command");
|
||||
validProgramEvents.push_back ("pre-shell-command");
|
||||
validProgramEvents.push_back ("post-shell-command");
|
||||
validProgramEvents.push_back ("pre-start-command");
|
||||
validProgramEvents.push_back ("post-start-command");
|
||||
validProgramEvents.push_back ("pre-stats-command");
|
||||
validProgramEvents.push_back ("post-stats-command");
|
||||
validProgramEvents.push_back ("pre-stop-command");
|
||||
validProgramEvents.push_back ("post-stop-command");
|
||||
validProgramEvents.push_back ("pre-summary-command");
|
||||
validProgramEvents.push_back ("post-summary-command");
|
||||
validProgramEvents.push_back ("pre-tags-command");
|
||||
validProgramEvents.push_back ("post-tags-command");
|
||||
validProgramEvents.push_back ("pre-timesheet-command");
|
||||
validProgramEvents.push_back ("post-timesheet-command");
|
||||
validProgramEvents.push_back ("pre-undo-command");
|
||||
validProgramEvents.push_back ("post-undo-command");
|
||||
validProgramEvents.push_back ("pre-usage-command");
|
||||
validProgramEvents.push_back ("post-usage-command");
|
||||
validProgramEvents.push_back ("pre-version-command");
|
||||
validProgramEvents.push_back ("post-version-command");
|
||||
|
||||
validTaskEvents.push_back ("pre-display");
|
||||
validTaskEvents.push_back ("pre-modification");
|
||||
validTaskEvents.push_back ("post-modification");
|
||||
validTaskEvents.push_back ("pre-delete");
|
||||
validTaskEvents.push_back ("post-delete");
|
||||
validTaskEvents.push_back ("pre-add");
|
||||
validTaskEvents.push_back ("post-add");
|
||||
validTaskEvents.push_back ("pre-undo");
|
||||
validTaskEvents.push_back ("post-undo");
|
||||
validTaskEvents.push_back ("pre-wait");
|
||||
validTaskEvents.push_back ("post-wait");
|
||||
validTaskEvents.push_back ("pre-unwait");
|
||||
validTaskEvents.push_back ("post-unwait");
|
||||
validTaskEvents.push_back ("pre-completed");
|
||||
validTaskEvents.push_back ("post-completed");
|
||||
validTaskEvents.push_back ("pre-priority-change");
|
||||
validTaskEvents.push_back ("post-priority-change");
|
||||
validTaskEvents.push_back ("pre-project-change");
|
||||
validTaskEvents.push_back ("post-project-change");
|
||||
validTaskEvents.push_back ("pre-substitution");
|
||||
validTaskEvents.push_back ("post-substitution");
|
||||
validTaskEvents.push_back ("pre-annotation");
|
||||
validTaskEvents.push_back ("post-annotation");
|
||||
validTaskEvents.push_back ("pre-tag");
|
||||
validTaskEvents.push_back ("post-tag");
|
||||
validTaskEvents.push_back ("pre-detag");
|
||||
validTaskEvents.push_back ("post-detag");
|
||||
validTaskEvents.push_back ("pre-colorization");
|
||||
validTaskEvents.push_back ("post-colorization");
|
||||
|
||||
validFieldEvents.push_back ("format-number");
|
||||
validFieldEvents.push_back ("format-date");
|
||||
validFieldEvents.push_back ("format-duration");
|
||||
validFieldEvents.push_back ("format-text");
|
||||
validFieldEvents.push_back ("format-id");
|
||||
validFieldEvents.push_back ("format-uuid");
|
||||
validFieldEvents.push_back ("format-project");
|
||||
validFieldEvents.push_back ("format-priority");
|
||||
validFieldEvents.push_back ("format-priority_long");
|
||||
validFieldEvents.push_back ("format-entry");
|
||||
validFieldEvents.push_back ("format-start");
|
||||
validFieldEvents.push_back ("format-end");
|
||||
validFieldEvents.push_back ("format-due");
|
||||
validFieldEvents.push_back ("format-countdown");
|
||||
validFieldEvents.push_back ("format-countdown_compact");
|
||||
validFieldEvents.push_back ("format-age");
|
||||
validFieldEvents.push_back ("format-age_compact");
|
||||
validFieldEvents.push_back ("format-active");
|
||||
validFieldEvents.push_back ("format-tags");
|
||||
validFieldEvents.push_back ("format-recur");
|
||||
validFieldEvents.push_back ("format-recurrence_indicator");
|
||||
validFieldEvents.push_back ("format-tag_indicator");
|
||||
validFieldEvents.push_back ("format-description_only");
|
||||
validFieldEvents.push_back ("format-description");
|
||||
validFieldEvents.push_back ("format-wait");
|
||||
validFieldEvents.push_back ("format-prompt");
|
||||
validFieldEvents.push_back ("format-depends");
|
||||
validProgramEvents.push_back ("on-file-read"); // Unimplemented
|
||||
validProgramEvents.push_back ("on-file-write"); // Unimplemented
|
||||
validProgramEvents.push_back ("on-synch"); // Unimplemented
|
||||
validProgramEvents.push_back ("on-merge"); // Unimplemented
|
||||
validProgramEvents.push_back ("on-gc"); // Unimplemented
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -395,36 +206,6 @@ bool Hooks::trigger (const std::string& event, Task& task)
|
|||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Field hooks.
|
||||
bool Hooks::trigger (
|
||||
const std::string& event,
|
||||
const std::string& name,
|
||||
std::string& value)
|
||||
{
|
||||
#ifdef HAVE_LIBLUA
|
||||
std::vector <Hook>::iterator it;
|
||||
for (it = all.begin (); it != all.end (); ++it)
|
||||
{
|
||||
if (it->event == event)
|
||||
{
|
||||
Timer timer (std::string ("Hooks::trigger ") + event);
|
||||
|
||||
if (validFieldEvent (event))
|
||||
{
|
||||
context.debug (std::string ("Event ") + event + " triggered");
|
||||
if (! api.callFieldHook (it->file, it->function, name, value))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
throw std::string ("Unrecognized hook event '") + event + "'.";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Hooks::validProgramEvent (const std::string& event)
|
||||
{
|
||||
|
@ -442,12 +223,4 @@ bool Hooks::validTaskEvent (const std::string& event)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Hooks::validFieldEvent (const std::string& event)
|
||||
{
|
||||
if (std::find (validFieldEvents.begin (), validFieldEvents.end (), event) != validFieldEvents.end ())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -60,12 +60,10 @@ public:
|
|||
|
||||
bool trigger (const std::string&); // Program
|
||||
bool trigger (const std::string&, Task&); // Task
|
||||
bool trigger (const std::string&, const std::string&, std::string&); // Field
|
||||
|
||||
private:
|
||||
bool validProgramEvent (const std::string&);
|
||||
bool validTaskEvent (const std::string&);
|
||||
bool validFieldEvent (const std::string&);
|
||||
|
||||
private:
|
||||
#ifdef HAVE_LIBLUA
|
||||
|
@ -75,7 +73,6 @@ private:
|
|||
|
||||
std::vector <std::string> validProgramEvents;
|
||||
std::vector <std::string> validTaskEvents;
|
||||
std::vector <std::string> validFieldEvents;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
11
src/TDB.cpp
11
src/TDB.cpp
|
@ -191,8 +191,6 @@ void TDB::location (const std::string& path)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDB::lock (bool lockFile /* = true */)
|
||||
{
|
||||
if (context.hooks.trigger ("pre-file-lock"))
|
||||
{
|
||||
mLock = lockFile;
|
||||
|
||||
mPending.clear ();
|
||||
|
@ -208,8 +206,6 @@ void TDB::lock (bool lockFile /* = true */)
|
|||
}
|
||||
|
||||
mAllOpenAndLocked = true;
|
||||
context.hooks.trigger ("post-file-lock");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -492,7 +488,6 @@ void TDB::update (const Task& task)
|
|||
int TDB::commit ()
|
||||
{
|
||||
Timer t ("TDB::commit");
|
||||
context.hooks.trigger ("pre-commit");
|
||||
|
||||
int quantity = mNew.size () + mModified.size ();
|
||||
|
||||
|
@ -512,7 +507,6 @@ int TDB::commit ()
|
|||
writeUndo (*task, mLocations[0].undo);
|
||||
|
||||
mNew.clear ();
|
||||
context.hooks.trigger ("post-commit");
|
||||
return quantity;
|
||||
}
|
||||
|
||||
|
@ -579,7 +573,6 @@ int TDB::commit ()
|
|||
mNew.clear ();
|
||||
}
|
||||
|
||||
context.hooks.trigger ("post-commit");
|
||||
return quantity;
|
||||
}
|
||||
|
||||
|
@ -713,7 +706,6 @@ int TDB::nextId ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDB::undo ()
|
||||
{
|
||||
context.hooks.trigger ("pre-undo");
|
||||
Directory location (context.config.get ("data.location"));
|
||||
|
||||
std::string undoFile = location.data + "/undo.data";
|
||||
|
@ -997,7 +989,6 @@ void TDB::undo ()
|
|||
!confirm ("The undo command is not reversible. Are you sure you want to revert to the previous state?"))
|
||||
{
|
||||
std::cout << "No changes made.\n";
|
||||
context.hooks.trigger ("post-undo");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1035,7 +1026,6 @@ void TDB::undo ()
|
|||
// Rewrite files.
|
||||
File::write (pendingFile, p);
|
||||
File::write (undoFile, u);
|
||||
context.hooks.trigger ("post-undo");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1074,7 +1064,6 @@ void TDB::undo ()
|
|||
}
|
||||
|
||||
std::cout << "Undo complete.\n";
|
||||
context.hooks.trigger ("post-undo");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
11
src/TDB2.cpp
11
src/TDB2.cpp
|
@ -341,8 +341,6 @@ void TDB::location (const std::string& path)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDB::lock (bool lockFile /* = true */)
|
||||
{
|
||||
if (context.hooks.trigger ("pre-file-lock"))
|
||||
{
|
||||
mLock = lockFile;
|
||||
|
||||
mPending.clear ();
|
||||
|
@ -358,8 +356,6 @@ void TDB::lock (bool lockFile /* = true */)
|
|||
}
|
||||
|
||||
mAllOpenAndLocked = true;
|
||||
context.hooks.trigger ("post-file-lock");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -642,7 +638,6 @@ void TDB::update (const Task& task)
|
|||
int TDB::commit ()
|
||||
{
|
||||
Timer t ("TDB::commit");
|
||||
context.hooks.trigger ("pre-commit");
|
||||
|
||||
int quantity = mNew.size () + mModified.size ();
|
||||
|
||||
|
@ -662,7 +657,6 @@ int TDB::commit ()
|
|||
writeUndo (*task, mLocations[0].undo);
|
||||
|
||||
mNew.clear ();
|
||||
context.hooks.trigger ("post-commit");
|
||||
return quantity;
|
||||
}
|
||||
|
||||
|
@ -729,7 +723,6 @@ int TDB::commit ()
|
|||
mNew.clear ();
|
||||
}
|
||||
|
||||
context.hooks.trigger ("post-commit");
|
||||
return quantity;
|
||||
}
|
||||
|
||||
|
@ -863,7 +856,6 @@ int TDB::nextId ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDB::undo ()
|
||||
{
|
||||
context.hooks.trigger ("pre-undo");
|
||||
Directory location (context.config.get ("data.location"));
|
||||
|
||||
std::string undoFile = location.data + "/undo.data";
|
||||
|
@ -1147,7 +1139,6 @@ void TDB::undo ()
|
|||
!confirm ("The undo command is not reversible. Are you sure you want to revert to the previous state?"))
|
||||
{
|
||||
std::cout << "No changes made.\n";
|
||||
context.hooks.trigger ("post-undo");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1185,7 +1176,6 @@ void TDB::undo ()
|
|||
// Rewrite files.
|
||||
File::write (pendingFile, p);
|
||||
File::write (undoFile, u);
|
||||
context.hooks.trigger ("post-undo");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1224,7 +1214,6 @@ void TDB::undo ()
|
|||
}
|
||||
|
||||
std::cout << "Undo complete.\n";
|
||||
context.hooks.trigger ("post-undo");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -974,8 +974,6 @@ int handleReportBurndownDaily (std::string& outs)
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-burndown-command"))
|
||||
{
|
||||
// Scan the pending tasks, applying any filter.
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
|
@ -1011,10 +1009,6 @@ int handleReportBurndownDaily (std::string& outs)
|
|||
|
||||
chart.scan (tasks);
|
||||
outs = chart.render ();
|
||||
|
||||
context.hooks.trigger ("post-burndown-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1023,8 +1017,6 @@ int handleReportBurndownWeekly (std::string& outs)
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-burndown-command"))
|
||||
{
|
||||
// Scan the pending tasks, applying any filter.
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
|
@ -1060,10 +1052,6 @@ int handleReportBurndownWeekly (std::string& outs)
|
|||
|
||||
chart.scan (tasks);
|
||||
outs = chart.render ();
|
||||
|
||||
context.hooks.trigger ("post-burndown-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1072,8 +1060,6 @@ int handleReportBurndownMonthly (std::string& outs)
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-burndown-command"))
|
||||
{
|
||||
// Scan the pending tasks, applying any filter.
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
|
@ -1109,10 +1095,6 @@ int handleReportBurndownMonthly (std::string& outs)
|
|||
|
||||
chart.scan (tasks);
|
||||
outs = chart.render ();
|
||||
|
||||
context.hooks.trigger ("post-burndown-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -2457,7 +2457,7 @@ void handleShell ()
|
|||
std::string prompt = context.config.get ("shell.prompt");
|
||||
if (context.hooks.trigger ("pre-shell-prompt"))
|
||||
{
|
||||
context.hooks.trigger ("format-prompt", "prompt", prompt);
|
||||
//context.hooks.trigger ("format-prompt", "prompt", prompt);
|
||||
std::cout << prompt << " ";
|
||||
}
|
||||
context.hooks.trigger ("post-shell-prompt");
|
||||
|
|
|
@ -53,9 +53,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-custom-report-command") &&
|
||||
context.hooks.trigger (std::string ("pre-") + report + "-command"))
|
||||
{
|
||||
// Load report configuration.
|
||||
std::string reportColumns = context.config.get ("report." + report + ".columns");
|
||||
std::string reportLabels = context.config.get ("report." + report + ".labels");
|
||||
|
@ -131,10 +128,7 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
table.setReportName (report);
|
||||
|
||||
foreach (task, tasks)
|
||||
{
|
||||
table.addRow ();
|
||||
context.hooks.trigger ("pre-display", *task);
|
||||
}
|
||||
|
||||
int columnCount = 0;
|
||||
int dueColumn = -1;
|
||||
|
@ -156,7 +150,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
else
|
||||
value = "-";
|
||||
|
||||
context.hooks.trigger ("format-id", "id", value);
|
||||
table.addCell (row++, columnCount, value);
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +165,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
foreach (task, tasks)
|
||||
{
|
||||
value = task->get ("uuid");
|
||||
context.hooks.trigger ("format-uuid", "uuid", value);
|
||||
table.addCell (row++, columnCount, value);
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +180,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
foreach (task, tasks)
|
||||
{
|
||||
value = task->get ("project");
|
||||
context.hooks.trigger ("format-project", "project", value);
|
||||
table.addCell (row++, columnCount, value);
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +194,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
foreach (task, tasks)
|
||||
{
|
||||
std::string value = task->get ("priority");
|
||||
context.hooks.trigger ("format-priority", "priority", value);
|
||||
table.addCell (row++, columnCount, value);
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +214,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
else if (pri == "M") pri = "Medium"; // TODO i18n
|
||||
else if (pri == "L") pri = "Low"; // TODO i18n
|
||||
|
||||
context.hooks.trigger ("format-priority_long", "priority", pri);
|
||||
table.addCell (row++, columnCount, pri);
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +232,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
{
|
||||
Date dt (::atoi (entered.c_str ()));
|
||||
entered = dt.toString (dateformat);
|
||||
context.hooks.trigger ("format-entry", "entry", entered);
|
||||
table.addCell (row, columnCount, entered);
|
||||
}
|
||||
}
|
||||
|
@ -263,7 +251,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
{
|
||||
Date dt (::atoi (started.c_str ()));
|
||||
started = dt.toString (dateformat);
|
||||
context.hooks.trigger ("format-start", "start", started);
|
||||
table.addCell (row, columnCount, started);
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +270,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
{
|
||||
Date dt (::atoi (ended.c_str ()));
|
||||
ended = dt.toString (dateformat);
|
||||
context.hooks.trigger ("format-end", "end", ended);
|
||||
table.addCell (row, columnCount, ended);
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +286,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
foreach (task, tasks)
|
||||
{
|
||||
std::string value = getDueDate (*task, dateformat);
|
||||
context.hooks.trigger ("format-due", "due", value);
|
||||
table.addCell (row++, columnCount, value);
|
||||
}
|
||||
|
||||
|
@ -323,7 +308,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
{
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
countdown = Duration (now - dt).format ();
|
||||
context.hooks.trigger ("format-countdown", "countdown", countdown);
|
||||
table.addCell (row, columnCount, countdown);
|
||||
}
|
||||
}
|
||||
|
@ -345,7 +329,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
{
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
countdown = Duration (now - dt).formatCompact ();
|
||||
context.hooks.trigger ("format-countdown_compact", "countdown_compact", countdown);
|
||||
table.addCell (row, columnCount, countdown);
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +350,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
{
|
||||
Date dt (::atoi (created.c_str ()));
|
||||
age = Duration (now - dt).format ();
|
||||
context.hooks.trigger ("format-age", "age", age);
|
||||
table.addCell (row, columnCount, age);
|
||||
}
|
||||
}
|
||||
|
@ -389,7 +371,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
{
|
||||
Date dt (::atoi (created.c_str ()));
|
||||
age = Duration (now - dt).formatCompact ();
|
||||
context.hooks.trigger ("format-age_compact", "age_compact", age);
|
||||
table.addCell (row, columnCount, age);
|
||||
}
|
||||
}
|
||||
|
@ -419,7 +400,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
{
|
||||
task->getTags (all);
|
||||
join (tags, " ", all);
|
||||
context.hooks.trigger ("format-tags", "tags", tags);
|
||||
table.addCell (row++, columnCount, tags);
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +415,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
foreach (task, tasks)
|
||||
{
|
||||
desc = task->get ("description");
|
||||
context.hooks.trigger ("format-description_only", "description_only", desc);
|
||||
table.addCell (row++, columnCount, desc);
|
||||
}
|
||||
}
|
||||
|
@ -451,7 +430,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
foreach (task, tasks)
|
||||
{
|
||||
desc = getFullDescription (*task, report);
|
||||
context.hooks.trigger ("format-description", "description", desc);
|
||||
table.addCell (row++, columnCount, desc);
|
||||
}
|
||||
}
|
||||
|
@ -467,7 +445,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
std::string recur = tasks[row].get ("recur");
|
||||
if (recur != "")
|
||||
{
|
||||
context.hooks.trigger ("format-recur", "recur", recur);
|
||||
table.addCell (row, columnCount, recur);
|
||||
}
|
||||
}
|
||||
|
@ -510,7 +487,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
{
|
||||
Date dt (::atoi (wait.c_str ()));
|
||||
wait = dt.toString (dateformat);
|
||||
context.hooks.trigger ("format-wait", "wait", wait);
|
||||
table.addCell (row++, columnCount, wait);
|
||||
}
|
||||
}
|
||||
|
@ -536,7 +512,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
blocked_ids.clear ();
|
||||
blocked.clear ();
|
||||
|
||||
context.hooks.trigger ("format-depends", "depends", deps);
|
||||
table.addCell (row++, columnCount, deps);
|
||||
}
|
||||
}
|
||||
|
@ -551,7 +526,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
foreach (task, tasks)
|
||||
{
|
||||
std::string value = format (task->urgency (), 4, 3);
|
||||
context.hooks.trigger ("format-urgency", "urgency", value);
|
||||
table.addCell (row++, columnCount, value);
|
||||
}
|
||||
}
|
||||
|
@ -689,10 +663,6 @@ int handleCustomReport (const std::string& report, std::string& outs)
|
|||
}
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger (std::string ("post-") + report + "-command");
|
||||
context.hooks.trigger ("post-custom-report-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -652,8 +652,6 @@ int handleEdit (std::string& outs)
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-edit-command"))
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
std::vector <Task> tasks;
|
||||
|
@ -675,9 +673,6 @@ int handleEdit (std::string& outs)
|
|||
context.tdb.unlock ();
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-edit-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,6 @@ extern Context context;
|
|||
int handleExportCSV (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-export-command"))
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
// Deliberately no 'id'.
|
||||
|
@ -71,20 +68,13 @@ int handleExportCSV (std::string& outs)
|
|||
context.tdb.unlock ();
|
||||
|
||||
foreach (task, tasks)
|
||||
{
|
||||
context.hooks.trigger ("pre-display", *task);
|
||||
|
||||
if (task->getStatus () != Task::recurring)
|
||||
out << task->composeCSV ().c_str ();
|
||||
}
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-export-command");
|
||||
|
||||
// Prevent messages from cluttering the export output.
|
||||
context.headers.clear ();
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -95,9 +85,6 @@ int handleExportCSV (std::string& outs)
|
|||
int handleExportiCal (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-export-command"))
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
out << "BEGIN:VCALENDAR\n"
|
||||
|
@ -114,8 +101,6 @@ int handleExportiCal (std::string& outs)
|
|||
|
||||
foreach (task, tasks)
|
||||
{
|
||||
context.hooks.trigger ("pre-display", *task);
|
||||
|
||||
if (task->getStatus () != Task::recurring)
|
||||
{
|
||||
out << "BEGIN:VTODO\n";
|
||||
|
@ -216,12 +201,9 @@ int handleExportiCal (std::string& outs)
|
|||
out << "END:VCALENDAR\n";
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-export-command");
|
||||
|
||||
// Prevent messages from cluttering the export output.
|
||||
context.headers.clear ();
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -230,8 +212,6 @@ int handleExportYAML (std::string& outs)
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-export-command"))
|
||||
{
|
||||
// YAML header.
|
||||
std::stringstream out;
|
||||
out << "%YAML 1.1\n"
|
||||
|
@ -246,20 +226,13 @@ int handleExportYAML (std::string& outs)
|
|||
context.tdb.unlock ();
|
||||
|
||||
foreach (task, tasks)
|
||||
{
|
||||
context.hooks.trigger ("pre-display", *task);
|
||||
out << task->composeYAML ().c_str ();
|
||||
}
|
||||
|
||||
out << "...\n";
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-export-command");
|
||||
|
||||
// Prevent messages from cluttering the export output.
|
||||
context.headers.clear ();
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,9 +39,6 @@ extern Context context;
|
|||
int handleReportHistoryMonthly (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-history-command"))
|
||||
{
|
||||
std::map <time_t, int> groups; // Represents any month with data
|
||||
std::map <time_t, int> addedGroup; // Additions by month
|
||||
std::map <time_t, int> completedGroup; // Completions by month
|
||||
|
@ -191,9 +188,6 @@ int handleReportHistoryMonthly (std::string& outs)
|
|||
}
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-history-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -201,9 +195,6 @@ int handleReportHistoryMonthly (std::string& outs)
|
|||
int handleReportHistoryAnnual (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-history-command"))
|
||||
{
|
||||
std::map <time_t, int> groups; // Represents any month with data
|
||||
std::map <time_t, int> addedGroup; // Additions by month
|
||||
std::map <time_t, int> completedGroup; // Completions by month
|
||||
|
@ -350,9 +341,6 @@ int handleReportHistoryAnnual (std::string& outs)
|
|||
}
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-history-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -360,9 +348,6 @@ int handleReportHistoryAnnual (std::string& outs)
|
|||
int handleReportGHistoryMonthly (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-ghistory-command"))
|
||||
{
|
||||
std::map <time_t, int> groups; // Represents any month with data
|
||||
std::map <time_t, int> addedGroup; // Additions by month
|
||||
std::map <time_t, int> completedGroup; // Completions by month
|
||||
|
@ -548,9 +533,6 @@ int handleReportGHistoryMonthly (std::string& outs)
|
|||
}
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-ghistory-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -558,9 +540,6 @@ int handleReportGHistoryMonthly (std::string& outs)
|
|||
int handleReportGHistoryAnnual (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-ghistory-command"))
|
||||
{
|
||||
std::map <time_t, int> groups; // Represents any month with data
|
||||
std::map <time_t, int> addedGroup; // Additions by month
|
||||
std::map <time_t, int> completedGroup; // Completions by month
|
||||
|
@ -742,9 +721,6 @@ int handleReportGHistoryAnnual (std::string& outs)
|
|||
}
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-ghistory-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -1264,9 +1264,6 @@ static std::string importYAML (const std::vector <std::string>& lines)
|
|||
int handleImport (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-import-command"))
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
// Use the description as a file name.
|
||||
|
@ -1349,9 +1346,6 @@ int handleImport (std::string& outs)
|
|||
throw std::string ("You must specify a file to import.");
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-import-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -298,9 +298,6 @@ int shortUsage (std::string& outs)
|
|||
int longUsage (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-usage-command"))
|
||||
{
|
||||
std::string shortUsageString;
|
||||
std::stringstream out;
|
||||
|
||||
|
@ -372,9 +369,6 @@ int longUsage (std::string& outs)
|
|||
<< "\n";
|
||||
|
||||
outs = out.str();
|
||||
context.hooks.trigger ("post-usage-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -384,8 +378,6 @@ int handleInfo (std::string& outs)
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-info-command"))
|
||||
{
|
||||
// Get all the tasks.
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
|
@ -433,14 +425,10 @@ int handleInfo (std::string& outs)
|
|||
table.setColumnJustification (1, Table::left);
|
||||
Date now;
|
||||
|
||||
context.hooks.trigger ("pre-display", *task);
|
||||
|
||||
// id
|
||||
int row = table.addRow ();
|
||||
table.addCell (row, 0, "ID");
|
||||
std::string value = format (task->id);
|
||||
context.hooks.trigger ("format-id", "id", value);
|
||||
table.addCell (row, 1, value);
|
||||
table.addCell (row, 1, format (task->id));
|
||||
|
||||
std::string status = ucFirst (Task::statusToText (task->getStatus ()));
|
||||
|
||||
|
@ -471,9 +459,7 @@ int handleInfo (std::string& outs)
|
|||
{
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "Priority");
|
||||
value = task->get ("priority");
|
||||
context.hooks.trigger ("format-priority", "priority", value);
|
||||
table.addCell (row, 1, value);
|
||||
table.addCell (row, 1, task->get ("priority"));
|
||||
}
|
||||
|
||||
// dependencies: blocked
|
||||
|
@ -515,9 +501,7 @@ int handleInfo (std::string& outs)
|
|||
{
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "Recurrence");
|
||||
value = task->get ("recur");
|
||||
context.hooks.trigger ("format-recur", "recur", value);
|
||||
table.addCell (row, 1, value);
|
||||
table.addCell (row, 1, task->get ("recur"));
|
||||
}
|
||||
|
||||
// until
|
||||
|
@ -566,9 +550,7 @@ int handleInfo (std::string& outs)
|
|||
if (format == "")
|
||||
format = context.config.get ("dateformat");
|
||||
|
||||
value = getDueDate (*task, format);
|
||||
context.hooks.trigger ("format-due", "due", value);
|
||||
table.addCell (row, 1, value);
|
||||
table.addCell (row, 1, getDueDate (*task, format));
|
||||
}
|
||||
|
||||
// wait
|
||||
|
@ -577,9 +559,7 @@ int handleInfo (std::string& outs)
|
|||
row = table.addRow ();
|
||||
table.addCell (row, 0, "Waiting until");
|
||||
Date dt (atoi (task->get ("wait").c_str ()));
|
||||
value = dt.toString (context.config.get ("dateformat"));
|
||||
context.hooks.trigger ("format-wait", "wait", value);
|
||||
table.addCell (row, 1, value);
|
||||
table.addCell (row, 1, dt.toString (context.config.get ("dateformat")));
|
||||
}
|
||||
|
||||
// start
|
||||
|
@ -588,10 +568,7 @@ int handleInfo (std::string& outs)
|
|||
row = table.addRow ();
|
||||
table.addCell (row, 0, "Start");
|
||||
Date dt (atoi (task->get ("start").c_str ()));
|
||||
|
||||
value = dt.toString (context.config.get ("dateformat"));
|
||||
context.hooks.trigger ("format-due", "due", value);
|
||||
table.addCell (row, 1, value);
|
||||
table.addCell (row, 1, dt.toString (context.config.get ("dateformat")));
|
||||
}
|
||||
|
||||
// end
|
||||
|
@ -600,9 +577,7 @@ int handleInfo (std::string& outs)
|
|||
row = table.addRow ();
|
||||
table.addCell (row, 0, "End");
|
||||
Date dt (atoi (task->get ("end").c_str ()));
|
||||
value = dt.toString (context.config.get ("dateformat"));
|
||||
context.hooks.trigger ("format-end", "end", value);
|
||||
table.addCell (row, 1, value);
|
||||
table.addCell (row, 1, dt.toString (context.config.get ("dateformat")));
|
||||
}
|
||||
|
||||
// tags ...
|
||||
|
@ -621,9 +596,8 @@ int handleInfo (std::string& outs)
|
|||
// uuid
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "UUID");
|
||||
std::string uuid = value = task->get ("uuid");
|
||||
context.hooks.trigger ("format-uuid", "uuid", value);
|
||||
table.addCell (row, 1, value);
|
||||
std::string uuid = task->get ("uuid");
|
||||
table.addCell (row, 1, uuid);
|
||||
|
||||
// entry
|
||||
row = table.addRow ();
|
||||
|
@ -639,7 +613,6 @@ int handleInfo (std::string& outs)
|
|||
age = Duration (now - dt).format ();
|
||||
}
|
||||
|
||||
context.hooks.trigger ("format-entry", "entry", entry);
|
||||
table.addCell (row, 1, entry + " (" + age + ")");
|
||||
|
||||
// fg
|
||||
|
@ -782,9 +755,6 @@ int handleInfo (std::string& outs)
|
|||
}
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-info-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -796,8 +766,6 @@ int handleReportSummary (std::string& outs)
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-summary-command"))
|
||||
{
|
||||
// Scan the pending tasks.
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
|
@ -933,9 +901,6 @@ int handleReportSummary (std::string& outs)
|
|||
}
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-summary-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -944,8 +909,6 @@ int handleReportTimesheet (std::string& outs)
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-timesheet-command"))
|
||||
{
|
||||
// Scan the pending tasks.
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
|
@ -1026,8 +989,6 @@ int handleReportTimesheet (std::string& outs)
|
|||
// If task completed within range.
|
||||
if (task->getStatus () == Task::completed)
|
||||
{
|
||||
context.hooks.trigger ("pre-display", *task);
|
||||
|
||||
Date compDate (atoi (task->get ("end").c_str ()));
|
||||
if (compDate >= start && compDate < end)
|
||||
{
|
||||
|
@ -1087,8 +1048,6 @@ int handleReportTimesheet (std::string& outs)
|
|||
if (task->getStatus () == Task::pending &&
|
||||
task->has ("start"))
|
||||
{
|
||||
context.hooks.trigger ("pre-display", *task);
|
||||
|
||||
Date startDate (atoi (task->get ("start").c_str ()));
|
||||
if (startDate >= start && startDate < end)
|
||||
{
|
||||
|
@ -1122,9 +1081,6 @@ int handleReportTimesheet (std::string& outs)
|
|||
}
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-timesheet-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1359,8 +1315,6 @@ int handleReportCalendar (std::string& outs)
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-calendar-command"))
|
||||
{
|
||||
// Each month requires 28 text columns width. See how many will actually
|
||||
// fit. But if a preference is specified, and it fits, use it.
|
||||
int width = context.getWidth ();
|
||||
|
@ -1723,9 +1677,6 @@ int handleReportCalendar (std::string& outs)
|
|||
}
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-calendar-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1733,9 +1684,6 @@ int handleReportCalendar (std::string& outs)
|
|||
int handleReportStats (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-stats-command"))
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
// Go get the file sizes.
|
||||
|
@ -1967,9 +1915,6 @@ int handleReportStats (std::string& outs)
|
|||
<< optionalBlankLine ();
|
||||
|
||||
outs = out.str ();
|
||||
context.hooks.trigger ("post-stats-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ if (open my $fh, '>', 'hook.rc')
|
|||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.pre-exit=" . $ENV{'PWD'} . "/hook:test\n";
|
||||
"hook.on-exit=" . $ENV{'PWD'} . "/hook:test\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
|
@ -35,7 +35,7 @@ if (open my $fh, '>', 'hook.rc')
|
|||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.post-start=" . $ENV{'PWD'} . "/hook:test\n";
|
||||
"hook.on-launch=" . $ENV{'PWD'} . "/hook:test\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue