mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-07 22:58:34 +02:00
Hooks
- Implemented ::onAdd.
This commit is contained in:
parent
8f14d83955
commit
0bb3be73da
1 changed files with 19 additions and 7 deletions
|
@ -158,19 +158,31 @@ void Hooks::onAdd (Task& after)
|
||||||
std::vector <std::string>::iterator i;
|
std::vector <std::string>::iterator i;
|
||||||
for (i = _scripts.begin (); i != _scripts.end (); ++i)
|
for (i = _scripts.begin (); i != _scripts.end (); ++i)
|
||||||
{
|
{
|
||||||
if (i->substr (0, 6) == "on-add")
|
if (i->find ("/on-add") != std::string::npos)
|
||||||
{
|
{
|
||||||
File script (*i);
|
File script (*i);
|
||||||
if (script.executable ())
|
if (script.executable ())
|
||||||
{
|
{
|
||||||
// TODO Call all modify hook scripts.
|
std::string input = after.composeJSON ();
|
||||||
|
std::string output;
|
||||||
|
int status = execute (*i, input, output);
|
||||||
|
|
||||||
// TODO On zero status:
|
std::vector <std::string> lines;
|
||||||
// - first line is modified JSON
|
split (lines, output, '\n');
|
||||||
// - remaining lines --> context.footnote
|
std::vector <std::string>::iterator line;
|
||||||
|
|
||||||
// TODO On non-zero status:
|
if (status == 0)
|
||||||
// - all stdout --> context.error
|
{
|
||||||
|
for (line = lines.begin (); line != lines.end (); ++line)
|
||||||
|
context.header (*line);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (line = lines.begin (); line != lines.end (); ++line)
|
||||||
|
context.error (*line);
|
||||||
|
|
||||||
|
throw 0; // This is how hooks silently terminate processing.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue