- ::onLaunch now conforms to design.
This commit is contained in:
Paul Beckingham 2014-05-14 22:39:56 -04:00
parent 3010ac667b
commit d70c8eef5c

View file

@ -222,40 +222,50 @@ void Hooks::onModify (const Task& before, Task& after)
{ {
context.timer_hooks.start (); context.timer_hooks.start ();
std::vector <std::string> matchingScripts = scripts ("on-modify");
std::vector <std::string>::iterator i; std::vector <std::string>::iterator i;
for (i = _scripts.begin (); i != _scripts.end (); ++i) for (i = matchingScripts.begin (); i != matchingScripts.end (); ++i)
{ {
if (i->find ("/on-modify") != std::string::npos) std::string afterJSON = after.composeJSON ();
std::string input = before.composeJSON ()
+ "\n"
+ afterJSON
+ "\n";
std::string output;
int status = execute (*i, input, output);
std::vector <std::string> lines;
split (lines, output, '\n');
std::vector <std::string>::iterator line;
if (status == 0)
{ {
File script (*i); bool first = true;
if (script.executable ()) for (line = lines.begin (); line != lines.end (); ++line)
{ {
std::string afterJSON = after.composeJSON (); if (line->length () && (*line)[0] == '{')
std::string input = before.composeJSON ()
+ "\n"
+ afterJSON;
std::string output;
int status = execute (*i, input, output);
std::vector <std::string> lines;
split (lines, output, '\n');
std::vector <std::string>::iterator line;
if (status == 0)
{ {
after = Task (afterJSON); Task newTask (*line);
for (line = lines.begin (); line != lines.end (); ++line)
context.footnote (*line); if (first)
{
after = newTask;
first = false;
}
else
context.tdb2.add (newTask);
} }
else else
{ context.footnote (*line);
for (line = lines.begin (); line != lines.end (); ++line)
context.error (*line);
throw 0; // This is how hooks silently terminate processing.
}
} }
} }
else
{
for (line = lines.begin (); line != lines.end (); ++line)
context.error (*line);
throw 0; // This is how hooks silently terminate processing.
}
} }
context.timer_hooks.stop (); context.timer_hooks.stop ();