aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2023-07-19 15:19:19 -0300
committerSilvio Rhatto <rhatto@riseup.net>2023-07-19 15:19:19 -0300
commitf2fc6d57656a8e7238efecd4afd0cc8c8c325e84 (patch)
tree58e7e5ae39f0c5ff7db0d8db09b74f9328d5163d
parentd87724345ff0227de597f00fd75a8dade0fe1eb3 (diff)
downloadscripts-f2fc6d57656a8e7238efecd4afd0cc8c8c325e84.tar.gz
scripts-f2fc6d57656a8e7238efecd4afd0cc8c8c325e84.tar.bz2
Feat: adds the collector script
-rwxr-xr-xcollector37
1 files changed, 37 insertions, 0 deletions
diff --git a/collector b/collector
new file mode 100755
index 0000000..0e5b50c
--- /dev/null
+++ b/collector
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+#
+# Collector: add, view, edit a collector file (from GTD/ZTD methodologies).
+#
+# The collector file is a Markdown file with the Task list extension, such as
+# https://docs.gitlab.com/ee/user/markdown.html#task-lists
+#
+
+# Parameters
+BASENAME="`basename $0`"
+ACTION="$1"
+
+# Check
+if [ -z "$COLLECTOR_FILE" ]; then
+ echo "$BASENAME: please export the COLLECTOR_FILE environment variable pointing to your collector markdown file"
+ exit 1
+elif [ ! -e "$COLLECTOR_FILE" ]; then
+ echo "$BASENAME: error: file not found: $COLLECTOR_FILE"
+ exit 1
+fi
+
+# Dispatch
+if [ -z "$ACTION" ] || [ "$ACTION" == "view" ]; then
+ cat "$COLLECTOR_FILE"
+elif [ "$ACTION" == "add" ]; then
+ shift
+ echo "* [ ] $*" >> "$COLLECTOR_FILE"
+elif [ "$ACTION" == "list" ]; then
+ grep -e "^\* \[ \]" "$COLLECTOR_FILE"
+elif [ "$ACTION" == "edit" ]; then
+ if [ ! -z "$EDITOR" ]; then
+ $EDITOR "$COLLECTOR_FILE"
+ else
+ echo "$BASENAME: error: please export the EDITOR environment variable pointing to your editor of choice"
+ exit 1
+ fi
+fi