mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-31 05:47:18 +02:00
Hooks
- Removed code supporting data modification during the on-exit event. - Fixed hook script interface descriptions.
This commit is contained in:
parent
4b70a26e60
commit
a9cf61c1d1
1 changed files with 25 additions and 42 deletions
|
@ -77,10 +77,10 @@ void Hooks::initialize ()
|
||||||
// - all emitted non-JSON lines are considered feedback messages
|
// - all emitted non-JSON lines are considered feedback messages
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// 0 Means: - all emitted JSON lines are added/modifiied
|
// 0 Means: - all emitted JSON lines are added/modified
|
||||||
// - all emitted non-JSON lines become footnote entries
|
// - all emitted non-JSON lines become footnote entries
|
||||||
// 1 Means: - all emitted JSON lines are ignored
|
// non-0 Means: - all emitted JSON lines are ignored
|
||||||
// - all emitted non-JSON lines become error entries
|
// - all emitted non-JSON lines become error entries
|
||||||
//
|
//
|
||||||
void Hooks::onLaunch ()
|
void Hooks::onLaunch ()
|
||||||
{
|
{
|
||||||
|
@ -114,9 +114,7 @@ void Hooks::onLaunch ()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (line = lines.begin (); line != lines.end (); ++line)
|
for (line = lines.begin (); line != lines.end (); ++line)
|
||||||
if (line->length () && (*line)[0] == '{')
|
if (line->length () && (*line)[0] != '{')
|
||||||
; // Ignored
|
|
||||||
else
|
|
||||||
context.error (*line);
|
context.error (*line);
|
||||||
|
|
||||||
throw 0; // This is how hooks silently terminate processing.
|
throw 0; // This is how hooks silently terminate processing.
|
||||||
|
@ -132,10 +130,12 @@ void Hooks::onLaunch ()
|
||||||
//
|
//
|
||||||
// Output:
|
// Output:
|
||||||
// - all emitted non-JSON lines are considered feedback messages
|
// - all emitted non-JSON lines are considered feedback messages
|
||||||
|
// - The onExit event occurs too late to allow any changes, so the input is not
|
||||||
|
// to be modified
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// 0 Means: - all emitted non-JSON lines become footnote entries
|
// 0 Means: - all emitted non-JSON lines become footnote entries
|
||||||
// 1 Means: - all emitted non-JSON lines become error entries
|
// non-0 Means: - all emitted non-JSON lines become error entries
|
||||||
bool Hooks::onExit ()
|
bool Hooks::onExit ()
|
||||||
{
|
{
|
||||||
context.timer_hooks.start ();
|
context.timer_hooks.start ();
|
||||||
|
@ -147,35 +147,24 @@ bool Hooks::onExit ()
|
||||||
std::vector <std::string>::iterator i;
|
std::vector <std::string>::iterator i;
|
||||||
for (i = matchingScripts.begin (); i != matchingScripts.end (); ++i)
|
for (i = matchingScripts.begin (); i != matchingScripts.end (); ++i)
|
||||||
{
|
{
|
||||||
|
std::string input;
|
||||||
std::string output;
|
std::string output;
|
||||||
std::vector <std::string> args;
|
std::vector <std::string> args;
|
||||||
int status = execute (*i, args, "", output);
|
int status = execute (*i, args, input, output);
|
||||||
|
|
||||||
std::vector <std::string> lines;
|
std::vector <std::string> lines;
|
||||||
split (lines, output, '\n');
|
split (lines, output, '\n');
|
||||||
std::vector <std::string>::iterator line;
|
std::vector <std::string>::iterator line;
|
||||||
|
|
||||||
if (status == 0)
|
for (line = lines.begin (); line != lines.end (); ++line)
|
||||||
{
|
{
|
||||||
for (line = lines.begin (); line != lines.end (); ++line)
|
if (line->length () && (*line)[0] != '{')
|
||||||
{
|
{
|
||||||
if (line->length () && (*line)[0] == '{')
|
if (status == 0)
|
||||||
{
|
|
||||||
Task newTask (*line);
|
|
||||||
context.tdb2.add (newTask);
|
|
||||||
status = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
context.footnote (*line);
|
context.footnote (*line);
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (line = lines.begin (); line != lines.end (); ++line)
|
|
||||||
if (line->length () && (*line)[0] == '{')
|
|
||||||
; // Ignored
|
|
||||||
else
|
else
|
||||||
context.error (*line);
|
context.error (*line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,10 +183,10 @@ bool Hooks::onExit ()
|
||||||
// - all emitted non-JSON lines are considered feedback messages
|
// - all emitted non-JSON lines are considered feedback messages
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// 0 Means: - all emitted JSON lines are added/modifiied
|
// 0 Means: - all emitted JSON lines are added/modified
|
||||||
// - all emitted non-JSON lines become footnote entries
|
// - all emitted non-JSON lines become footnote entries
|
||||||
// 1 Means: - all emitted JSON lines are ignored
|
// non-0 Means: - all emitted JSON lines are ignored
|
||||||
// - all emitted non-JSON lines become error entries
|
// - all emitted non-JSON lines become error entries
|
||||||
//
|
//
|
||||||
void Hooks::onAdd (Task& after)
|
void Hooks::onAdd (Task& after)
|
||||||
{
|
{
|
||||||
|
@ -240,12 +229,8 @@ void Hooks::onAdd (Task& after)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (line = lines.begin (); line != lines.end (); ++line)
|
for (line = lines.begin (); line != lines.end (); ++line)
|
||||||
{
|
if (line->length () && (*line)[0] != '{')
|
||||||
if (line->length () && (*line)[0] == '{')
|
|
||||||
; // Ignored
|
|
||||||
else
|
|
||||||
context.error (*line);
|
context.error (*line);
|
||||||
}
|
|
||||||
|
|
||||||
throw 0; // This is how hooks silently terminate processing.
|
throw 0; // This is how hooks silently terminate processing.
|
||||||
}
|
}
|
||||||
|
@ -266,10 +251,10 @@ void Hooks::onAdd (Task& after)
|
||||||
// - all emitted non-JSON lines are considered feedback messages
|
// - all emitted non-JSON lines are considered feedback messages
|
||||||
//
|
//
|
||||||
// Exit:
|
// Exit:
|
||||||
// 0 Means: - all emitted JSON lines are added/modifiied
|
// 0 Means: - all emitted JSON lines are added/modified
|
||||||
// - all emitted non-JSON lines become footnote entries
|
// - all emitted non-JSON lines become footnote entries
|
||||||
// 1 Means: - all emitted JSON lines are ignored
|
// non-0 Means: - all emitted JSON lines are ignored
|
||||||
// - all emitted non-JSON lines become error entries
|
// - all emitted non-JSON lines become error entries
|
||||||
void Hooks::onModify (const Task& before, Task& after)
|
void Hooks::onModify (const Task& before, Task& after)
|
||||||
{
|
{
|
||||||
context.timer_hooks.start ();
|
context.timer_hooks.start ();
|
||||||
|
@ -315,9 +300,7 @@ void Hooks::onModify (const Task& before, Task& after)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (line = lines.begin (); line != lines.end (); ++line)
|
for (line = lines.begin (); line != lines.end (); ++line)
|
||||||
if (line->length () && (*line)[0] == '{')
|
if (line->length () && (*line)[0] != '{')
|
||||||
; // Ignored
|
|
||||||
else
|
|
||||||
context.error (*line);
|
context.error (*line);
|
||||||
|
|
||||||
throw 0; // This is how hooks silently terminate processing.
|
throw 0; // This is how hooks silently terminate processing.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue