about summary refs log tree commit diff stats
path: root/modules/by-name/ts/tskm/taskwarrior_hooks
diff options
context:
space:
mode:
Diffstat (limited to 'modules/by-name/ts/tskm/taskwarrior_hooks')
-rwxr-xr-xmodules/by-name/ts/tskm/taskwarrior_hooks/enforce-projects.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/by-name/ts/tskm/taskwarrior_hooks/enforce-projects.sh b/modules/by-name/ts/tskm/taskwarrior_hooks/enforce-projects.sh
new file mode 100755
index 00000000..217e6052
--- /dev/null
+++ b/modules/by-name/ts/tskm/taskwarrior_hooks/enforce-projects.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env sh
+
+new_task="$1"
+
+project="$(echo "$new_task" | jq '.project' --raw-output)"
+[ "$project" = "null" ] && die "No project supplied!"
+
+if ! tskm projects list | grep -q "^$project$"; then
+    die "The project '$project' is not (yet) registered, registered projects: $(tskm projects list | tr '\n' ',')"
+fi
+
+# vim: ft=sh