Separated script into multiple files for easier management. Added Makefile
[bash-notes.git] / SOURCE / CORE / core-show.sh
diff --git a/SOURCE/CORE/core-show.sh b/SOURCE/CORE/core-show.sh
new file mode 100644 (file)
index 0000000..1a04c82
--- /dev/null
@@ -0,0 +1,17 @@
+function shownote() {
+       NOTE=$1
+
+       # shellcheck disable=SC2155
+       local OK=$(check_noteID "$NOTE")
+       if [ ! "$OK" ]; then
+               echo "invalid note \"$NOTE\""
+               echo "Use the note ID that you can fetch after listing your notes"
+               exit 1
+       fi
+
+       FILE=$($JQ -r --arg i $OK '.notes[] | select(.id == $i) | .file' $DB)
+
+       if [ "$FILE" ]; then
+               $PAGER ${NOTESDIR}/${FILE}
+       fi
+}