2 # remove eventually existing temp DB file
3 if [[ -f $TMPDB ]]; then
8 if [ "all" == "$NOTE" ]; then
9 echo "You're going to delete all notes."
10 read -r -p "Do you wish to continue? (y/N) " ANSWER
13 # shellcheck disable=SC2086
14 $JQ 'del(.notes[])' $DB > $TMPDB
15 # shellcheck disable=SC2086
17 # shellcheck disable=SC2086
20 echo "Deleted all notes"
23 echo "Aborting, no notes were deleted."
28 # shellcheck disable=SC2155
29 local OK
=$
(check_noteID
"$NOTE")
31 echo "invalid note \"$NOTE\""
32 echo "Use the note ID that you can fetch after listing your notes"
37 # shellcheck disable=SC2016,SC2086
38 TITLE
=$
($JQ --arg i
$OK '.notes[] | select(.id == $i) | .title' $DB)
39 # shellcheck disable=SC2016,SC2086
40 FILE
=$
($JQ -r --arg i
$OK '.notes[] | select(.id == $i) | .file' $DB)
42 # shellcheck disable=SC2016,SC2086
43 $JQ -r --arg i
$OK 'del(.notes[] | select(.id == $i))' $DB > $TMPDB
44 # shellcheck disable=SC2086
48 echo "Deleted note $TITLE"