reimplemented title dialog when adding note if nothing is passed on the command line.
[bash-notes.git] / SOURCE / CORE / core-add.sh
index c6dee8a..3404f71 100644 (file)
@@ -1,13 +1,27 @@
 addnote() {
        # attempt syncing before adding a note
-       gitsync
+       gitsync -f
        # remove eventually existing temp DB file
        if [[ -f $TMPDB ]]; then
                rm $TMPDB
        fi
 
+       # RANDOM TITLE
        RTITLE=$(random_title)
-       [[ -z "$1" ]] && NOTETITLE="$RTITLE" || NOTETITLE="$1"
+
+       if [[ -z $1 ]]; then
+               read -r -p "Title: " TITLE
+               case "$TITLE" in
+                       '' )
+                               NOTETITLE="$RTITLE"
+                               ;;
+                       * )
+                               NOTETITLE=$TITLE
+                               ;;
+               esac
+       fi
+
+       # [[ -z "$1" ]] && NOTETITLE="$RTITLE" || NOTETITLE="$1"
        echo "adding new note - \"$NOTETITLE\""
        # shellcheck disable=SC2086
        LASTID=$($JQ '.notes[-1].id // 0 | tonumber' $DB)