mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Hooks: Implement "Hooks v2" API
- All hook scripts now receive key:value pair command line arguments. - Add only the basics: api, args, command, rc, data. Possibly more to come.
This commit is contained in:
parent
5d4859c44d
commit
04d0c52a43
2 changed files with 27 additions and 0 deletions
|
@ -520,6 +520,30 @@ void Hooks::assertFeedback (const std::vector <std::string>& input) const
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::vector <std::string>& Hooks::buildHookScriptArgs (std::vector <std::string>& 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 <std::string> args;
|
||||
int status;
|
||||
|
||||
buildHookScriptArgs (args);
|
||||
|
||||
// Measure time for each hook if running in debug
|
||||
if (_debug >= 2)
|
||||
{
|
||||
|
|
|
@ -57,6 +57,7 @@ private:
|
|||
void assertNTasks (const std::vector <std::string>&, unsigned int) const;
|
||||
void assertSameTask (const std::vector <std::string>&, const Task&) const;
|
||||
void assertFeedback (const std::vector <std::string>&) const;
|
||||
std::vector <std::string>& buildHookScriptArgs (std::vector <std::string>&);
|
||||
int callHookScript (const std::string&, const std::vector <std::string>&, std::vector <std::string>&);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue