mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-07 22:58:34 +02:00
Hooks
- ::onLaunch now conforms to design.
This commit is contained in:
parent
3010ac667b
commit
d70c8eef5c
1 changed files with 35 additions and 25 deletions
|
@ -222,18 +222,15 @@ void Hooks::onModify (const Task& before, Task& after)
|
|||
{
|
||||
context.timer_hooks.start ();
|
||||
|
||||
std::vector <std::string> matchingScripts = scripts ("on-modify");
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = _scripts.begin (); i != _scripts.end (); ++i)
|
||||
{
|
||||
if (i->find ("/on-modify") != std::string::npos)
|
||||
{
|
||||
File script (*i);
|
||||
if (script.executable ())
|
||||
for (i = matchingScripts.begin (); i != matchingScripts.end (); ++i)
|
||||
{
|
||||
std::string afterJSON = after.composeJSON ();
|
||||
std::string input = before.composeJSON ()
|
||||
+ "\n"
|
||||
+ afterJSON;
|
||||
+ afterJSON
|
||||
+ "\n";
|
||||
std::string output;
|
||||
int status = execute (*i, input, output);
|
||||
|
||||
|
@ -243,10 +240,25 @@ void Hooks::onModify (const Task& before, Task& after)
|
|||
|
||||
if (status == 0)
|
||||
{
|
||||
after = Task (afterJSON);
|
||||
bool first = true;
|
||||
for (line = lines.begin (); line != lines.end (); ++line)
|
||||
{
|
||||
if (line->length () && (*line)[0] == '{')
|
||||
{
|
||||
Task newTask (*line);
|
||||
|
||||
if (first)
|
||||
{
|
||||
after = newTask;
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
context.tdb2.add (newTask);
|
||||
}
|
||||
else
|
||||
context.footnote (*line);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (line = lines.begin (); line != lines.end (); ++line)
|
||||
|
@ -255,8 +267,6 @@ void Hooks::onModify (const Task& before, Task& after)
|
|||
throw 0; // This is how hooks silently terminate processing.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.timer_hooks.stop ();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue