- TITLE=$($JQ --arg i $OK '.notes[] | select(.id == $i) | .title' $DB)
- FILE=$($JQ -r --arg i $OK '.notes[] | select(.id == $i) | .file' $DB)
- if [ "$TITLE" ]; then
- $JQ -r --arg i $OK 'del(.notes[] | select(.id == $i))' $DB > $TMPDB
- mv $TMPDB $DB
- rm $NOTESDIR/$FILE
- echo "Deleted note $TITLE"
+ NOTE=$1
+ if [ "all" == $NOTE ]; then
+ echo "You're going to delete all notes."
+ read -r -p "Do you wish to continue? (y/N) " ANSWER
+ case $ANSWER in
+ y|Y )
+ $JQ 'del(.notes[])' $DB > $TMPDB
+ mv $TMPDB $DB
+ rm $NOTESDIR/*
+ echo "Deleted all notes"
+ ;;
+ * )
+ echo "Aborting, no notes were deleted."
+ exit 1
+ ;;
+ esac