mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Hooks
- ::onExit now comforms to design.
This commit is contained in:
parent
b1c0e67581
commit
0d2bc00527
1 changed files with 23 additions and 16 deletions
|
@ -118,28 +118,35 @@ void Hooks::onExit ()
|
||||||
{
|
{
|
||||||
context.timer_hooks.start ();
|
context.timer_hooks.start ();
|
||||||
|
|
||||||
|
std::vector <std::string> matchingScripts = scripts ("on-exit");
|
||||||
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-exit") != std::string::npos)
|
std::string output;
|
||||||
|
int status = execute (*i, "", output);
|
||||||
|
|
||||||
|
std::vector <std::string> lines;
|
||||||
|
split (lines, output, '\n');
|
||||||
|
std::vector <std::string>::iterator line;
|
||||||
|
|
||||||
|
if (status == 0)
|
||||||
{
|
{
|
||||||
File script (*i);
|
for (line = lines.begin (); line != lines.end (); ++line)
|
||||||
if (script.executable ())
|
|
||||||
{
|
{
|
||||||
std::string output;
|
if (line->length () && (*line)[0] == '{')
|
||||||
int status = execute (*i, "", output);
|
{
|
||||||
|
Task newTask (*line);
|
||||||
std::vector <std::string> lines;
|
context.tdb2.add (newTask);
|
||||||
split (lines, output, '\n');
|
}
|
||||||
std::vector <std::string>::iterator line;
|
else
|
||||||
|
context.footnote (*line);
|
||||||
for (line = lines.begin (); line != lines.end (); ++line)
|
|
||||||
if (status == 0)
|
|
||||||
context.footnote (*line);
|
|
||||||
else
|
|
||||||
context.error (*line);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (line = lines.begin (); line != lines.end (); ++line)
|
||||||
|
context.error (*line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.timer_hooks.stop ();
|
context.timer_hooks.stop ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue