aboutsummaryrefslogtreecommitdiff
path: root/libexec/recit-edit-entry
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2022-07-14 03:40:24 +0000
committerJulio Capote <jcapote@gmail.com>2022-07-14 03:40:24 +0000
commit891f946e86f8a0911f67983d52fccacc9f8ebbad (patch)
tree36b032deb891f4adf5c047b255eb0ca6da275fef /libexec/recit-edit-entry
downloadrecit-891f946e86f8a0911f67983d52fccacc9f8ebbad.tar.gz
initial
Diffstat (limited to 'libexec/recit-edit-entry')
-rwxr-xr-xlibexec/recit-edit-entry32
1 files changed, 32 insertions, 0 deletions
diff --git a/libexec/recit-edit-entry b/libexec/recit-edit-entry
new file mode 100755
index 0000000..0636bc6
--- /dev/null
+++ b/libexec/recit-edit-entry
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# Usage: recit edit-entry uuid
+
+set -e
+
+# shellcheck source=/dev/null
+source lib/loader
+
+recfile=$(load_recit)
+
+uuid=$1
+
+notes=$(recsel -e "Id = '$uuid'" -t Entry -P Notes "${recfile}")
+time=$(recsel -e "Id = '$uuid'" -t Entry -P Time "${recfile}")
+
+if [[ -z $notes ]]; then
+ echo "record not found"
+ exit 1
+fi
+
+if [[ -z ${EDITOR+x} ]]; then
+ echo "$EDITOR is not defined please pass a message"
+ exit 1
+fi
+
+tmpfile="$(mktemp)"
+echo "$notes" > $tmpfile
+command $EDITOR "$tmpfile"
+notes=$(cat "$tmpfile")
+rm "$tmpfile"
+
+recins -e "Id = '$uuid'" -t Entry -f Id -v "$uuid" -f Notes -v "$notes" -f Time -v "$time" "${recfile}"