- Removed the ability for hooks to add tasks, or modify tasks that are outside
  the context of the current event. This makes hooks a local mechanism that
  operates only on local changes. Modifications/additions coming in via sync
  command are not processed by hooks.
This commit is contained in:
Paul Beckingham 2015-01-31 17:47:58 -05:00
parent 61291e4d1e
commit 1cfdfbae52
9 changed files with 139 additions and 158 deletions

View file

@ -1,20 +1,19 @@
#!/bin/bash
# The on-add event is triggered separately for each task added
# The on-add event is triggered separately for each task added. This hook
# script can accept/reject the addition. Processing will continue.
# Input:
# - line of JSON for the task added
# Output:
# - all emitted JSON lines are added/modified as tasks, if the exit code is
# zero, otherwise ignored.
# - minimal new task: {"description":"Buy milk"}
# - to modify a task include complete JSON
# - all emitted non-JSON lines are considered feedback messages if the exit
# code is zero, otherwise they are considered errors.
# - Line of JSON for proposed new task.
read new_task
# Output:
# - JSON, modified or unmodified.
# - Optional feedback/error.
echo $new_task
echo 'on-add'
# Status:
# - 0: JSON accepted, non-JSON is feedback.
# - non-0: JSON ignored, non-JSON is error.
exit 0

View file

@ -1,20 +1,20 @@
#!/bin/bash
# The on-exit event is triggered once, after all processing is complete, i.e.
# last
# The on-exit event is triggered once, after all processing is complete.
# This hooks script has no effect on processing.
# Input:
# - read-only line of JSON for each task added/modified
# Output:
# - any emitted JSON is ignored
# - all emitted non-JSON lines are considered feedback messages if the exit
# code is zero, otherwise they are considered errors.
while read -t 1 modified_task
# - Read-only line of JSON for each task added/modified
while read modified_task
do
# Scan task
echo $modified_task
done
# Output:
# - Optional feedback/error.
echo 'on-exit'
# Status:
# - 0: JSON ignored, non-JSON is feedback.
# - non-0: JSON ignored, non-JSON is error.
exit 0

View file

@ -1,18 +1,17 @@
#!/bin/bash
# The on-launch event is triggered once, after initialization, before any
# processing occurs, i.e first
# processing occurs. This hooks script has no effect on processing.
# Input:
# - none
# - None
# Output:
# - all emitted JSON lines are added/modified as tasks, if the exit code is
# zero, otherwise ignored.
# - minimal new task: {"description":"Buy milk"}
# - to modify a task include complete JSON
# - all emitted non-JSON lines are considered feedback messages if the exit
# code is zero, otherwise they are considered errors.
# - Optional feedback/error.
echo 'on-launch'
# Status:
# - 0: JSON ignored, non-JSON is feedback.
# - non-0: JSON ignored, non-JSON is error.
exit 0

View file

@ -1,22 +1,21 @@
#!/bin/bash
# The on-modify event is triggered separately for each task added or modified
# The on-modify event is triggered separately for each task modified. This hook
# script can accept/reject the modification. Processing will continue.
# Input:
# - line of JSON for the original task
# - line of JSON for the modified task, the diff being the modification
# Output:
# - all emitted JSON lines are added/modified as tasks, if the exit code is
# zero, otherwise ignored.
# - minimal new task: {"description":"Buy milk"}
# - to modify a task include complete JSON
# - all emitted non-JSON lines are considered feedback messages if the exit
# code is zero, otherwise they are considered errors.
read original_task
read modified_task
# Output:
# - JSON, modified or unmodified.
# - Optional feedback/error.
echo $modified_task
echo 'on-modify'
# Status:
# - 0: JSON accepted, non-JSON is feedback.
# - non-0: JSON ignored, non-JSON is error.
exit 0