aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanix <danix@danix.xyz>2023-04-26 16:50:50 +0200
committerdanix <danix@danix.xyz>2023-04-26 16:50:50 +0200
commit1e68b305cbd15dd961f6bc225985a0427e8a4535 (patch)
tree352395cf3a2045b558380ff86a22f5ce69483ca1
parent79f10f4efc3cc082749eb4154862bc3221e87e27 (diff)
downloadbash-notes-1e68b305cbd15dd961f6bc225985a0427e8a4535.tar.gz
bash-notes-1e68b305cbd15dd961f6bc225985a0427e8a4535.zip
reimplemented title dialog when adding note if nothing is passed on the command line.
-rw-r--r--SOURCE/CORE/core-add.sh16
-rw-r--r--SOURCE/main.sh2
-rwxr-xr-xnotes.sh18
3 files changed, 32 insertions, 4 deletions
diff --git a/SOURCE/CORE/core-add.sh b/SOURCE/CORE/core-add.sh
index 58831e4..3404f71 100644
--- a/SOURCE/CORE/core-add.sh
+++ b/SOURCE/CORE/core-add.sh
@@ -6,8 +6,22 @@ addnote() {
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)
diff --git a/SOURCE/main.sh b/SOURCE/main.sh
index 6198adb..c2822d9 100644
--- a/SOURCE/main.sh
+++ b/SOURCE/main.sh
@@ -1,5 +1,5 @@
# shellcheck disable=SC2006
-GOPT=$(getopt -o hvplr:a:e:d:s: --long help,version,list,plain,userconf,showconf,sync,restore:,backup:,add:,edit:,delete:,show: -n 'bash-notes' -- "$@")
+GOPT=$(getopt -o hvplr:a::e:d:s: --long help,version,list,plain,userconf,showconf,sync,restore:,backup:,add::,edit:,delete:,show: -n 'bash-notes' -- "$@")
# shellcheck disable=SC2181
if [ $? != 0 ] ; then helptext >&2 ; exit 1 ; fi
diff --git a/notes.sh b/notes.sh
index 87b8a77..a9afd60 100755
--- a/notes.sh
+++ b/notes.sh
@@ -381,8 +381,22 @@ addnote() {
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)
@@ -612,7 +626,7 @@ shownote() {
fi
}
# shellcheck disable=SC2006
-GOPT=$(getopt -o hvplr:a:e:d:s: --long help,version,list,plain,userconf,showconf,sync,restore:,backup:,add:,edit:,delete:,show: -n 'bash-notes' -- "$@")
+GOPT=$(getopt -o hvplr:a::e:d:s: --long help,version,list,plain,userconf,showconf,sync,restore:,backup:,add::,edit:,delete:,show: -n 'bash-notes' -- "$@")
# shellcheck disable=SC2181
if [ $? != 0 ] ; then helptext >&2 ; exit 1 ; fi