Use more consistent error messages, and fix the error message for the delete operation when no name has been provided

This commit is contained in:
Kevin MacMartin 2023-08-23 22:08:01 -04:00
parent bd83c4081d
commit 4057ab8d0e

10
vnotes
View file

@ -57,7 +57,7 @@ function create_note {
note="$VNOTES_FOLDER/${1}.$VNOTES_EXTENSION" note="$VNOTES_FOLDER/${1}.$VNOTES_EXTENSION"
"$EDITOR" "$note" "$EDITOR" "$note"
else else
printf '%s %s\n' "${c_r}ERROR:$c_c" 'No name given for the new note' >&2 printf '%s %s\n' "${c_r}ERROR:$c_c" "${c_w}The name of the note to ${c_y}create$c_w was not provided$c_c" >&2
exit 1 exit 1
fi fi
} }
@ -69,13 +69,13 @@ function delete_note {
if [[ -f "$note" ]]; then if [[ -f "$note" ]]; then
rm "$note" rm "$note"
printf '%s\n' "${c_w}The note '${c_m}$1${c_w}' has been ${c_r}DELETED$c_c" printf '%s\n' "${c_w}The note ${c_m}$1${c_w} has been ${c_r}DELETED$c_c"
else else
printf '%s %s\n' "${c_r}ERROR:$c_c" "${c_w}The note '${c_m}$1${c_w}' doesn't exist" >&2 printf '%s %s\n' "${c_r}ERROR:$c_c" "${c_w}The note ${c_m}$1${c_w} doesn't exist" >&2
exit 1 exit 1
fi fi
else else
printf '%s %s\n' "${c_r}ERROR:$c_c" 'No name given for the new note' >&2 printf '%s %s\n' "${c_r}ERROR:$c_c" "${c_w}The name of the note to ${c_y}delete$c_w was not provided$c_c" >&2
exit 1 exit 1
fi fi
} }
@ -155,7 +155,7 @@ function search_notes {
# Exit with an error if the list of notes is empty # Exit with an error if the list of notes is empty
(( ${#documents[*]} )) || { (( ${#documents[*]} )) || {
printf '%s\n' "${c_r}ERROR:$c_w Can't find ${key}$c_c" printf '%s\n' "${c_r}ERROR:$c_w Unable to find ${c_m}${key}${c_w}$c_c"
exit 1 exit 1
} }