- ::onAdd now conforms to design.
This commit is contained in:
Paul Beckingham
2014-05-14 22:39:35 -04:00
parent 0d2bc00527
commit 3010ac667b

View File

@@ -164,15 +164,11 @@ void Hooks::onAdd (Task& after)
{ {
context.timer_hooks.start (); context.timer_hooks.start ();
std::vector <std::string> matchingScripts = scripts ("on-add");
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-add") != std::string::npos) std::string input = after.composeJSON () + "\n";
{
File script (*i);
if (script.executable ())
{
std::string input = after.composeJSON ();
std::string output; std::string output;
int status = execute (*i, input, output); int status = execute (*i, input, output);
@@ -182,9 +178,25 @@ void Hooks::onAdd (Task& after)
if (status == 0) if (status == 0)
{ {
bool first = true;
for (line = lines.begin (); line != lines.end (); ++line) 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); context.footnote (*line);
} }
}
else else
{ {
for (line = lines.begin (); line != lines.end (); ++line) for (line = lines.begin (); line != lines.end (); ++line)
@@ -193,8 +205,6 @@ void Hooks::onAdd (Task& after)
throw 0; // This is how hooks silently terminate processing. throw 0; // This is how hooks silently terminate processing.
} }
} }
}
}
context.timer_hooks.stop (); context.timer_hooks.stop ();
} }