diff --git a/src/Hooks.cpp b/src/Hooks.cpp index eaf171543..ca2eafd03 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -520,6 +520,30 @@ void Hooks::assertFeedback (const std::vector & input) const } } +//////////////////////////////////////////////////////////////////////////////// +std::vector & Hooks::buildHookScriptArgs (std::vector & args) +{ + Variant v; + + // Hooks API version. + args.push_back ("api:2"); + + // Command line Taskwarrior was called with. + context.dom.get ("context.args", v); + args.push_back ("args:" + std::string (v)); + + // Command to be executed. + args.push_back ("command:" + context.cli.getCommand ()); + + // rc file used after applying all overrides. + args.push_back ("rc:" + context.rc_file._data); + + // Directory containing *.data files. + args.push_back ("data:" + context.data_dir._data); + + return args; +} + //////////////////////////////////////////////////////////////////////////////// int Hooks::callHookScript ( const std::string& script, @@ -546,6 +570,8 @@ int Hooks::callHookScript ( std::vector args; int status; + buildHookScriptArgs (args); + // Measure time for each hook if running in debug if (_debug >= 2) { diff --git a/src/Hooks.h b/src/Hooks.h index 1bb33a2f7..0040303e6 100644 --- a/src/Hooks.h +++ b/src/Hooks.h @@ -57,6 +57,7 @@ private: void assertNTasks (const std::vector &, unsigned int) const; void assertSameTask (const std::vector &, const Task&) const; void assertFeedback (const std::vector &) const; + std::vector & buildHookScriptArgs (std::vector &); int callHookScript (const std::string&, const std::vector &, std::vector &); private: