From: danix Date: Fri, 24 Mar 2023 15:50:37 +0000 (+0100) Subject: added 'plain' parameter to output plain text without markup X-Git-Tag: v0.2~12 X-Git-Url: https://git.danix.xyz/?p=bash-notes.git;a=commitdiff_plain;h=c018122c134d4a9dafe623425f768e15da94ca57 added 'plain' parameter to output plain text without markup --- diff --git a/notes.sh b/notes.sh index edec94d..fa54bae 100644 --- a/notes.sh +++ b/notes.sh @@ -58,7 +58,7 @@ echo $PID > $PIDFILE function helptext() { echo "Usage:" - echo " $0 [OPTION] ..." + echo " $0 [PARAMS] ..." echo "" cat << __NOWCONF__ ${BASENAME} configuration is: @@ -67,6 +67,7 @@ base directory: ${BASEDIR}/ notes archive: ${NOTESDIR}/ notes database: ${DB} rc file: $RCFILE + text editor: ${EDITOR} terminal: ${TERMINAL} jq executable: ${JQ} @@ -75,6 +76,8 @@ __NOWCONF__ echo "" echo "The script's parameters are:" echo " -h | --help : This help text" + echo " -p | --plain : Output is in plain text" + echo " (without this option the output is colored)" echo " -l | --list : List existing notes" echo " -a | --add : Add new note" echo " -m | --modify <note> : Modify note" @@ -98,6 +101,7 @@ function addnote() { function listnotes() { echo "listing all notes" + [ $PLAIN == true ] && echo "output is plain text" || echo "output is colored" echo "" echo "[ID] [TITLE]" for i in ${NOTESDIR}/*; do @@ -197,7 +201,7 @@ fi # NOTE: This requires GNU getopt. On Mac OS X and FreeBSD, you have to install this # separately; see below. -GOPT=`getopt -o hvla:m:d:r: --long help,version,list,userconf,add:,modify:,date:,remove:,editor:,storage: \ +GOPT=`getopt -o hvpla:m:d:r: --long help,version,list,plain,userconf,add:,modify:,date:,remove:,editor:,storage: \ -n 'bash-notes' -- "$@"` if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi @@ -205,6 +209,8 @@ if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi # Note the quotes around `$GOPT': they are essential! eval set -- "$GOPT" +PLAIN=false + while true; do case "$1" in -h | --help ) @@ -215,6 +221,10 @@ while true; do echo $BASENAME v${VERSION} exit ;; + -p | --plain ) + PLAIN=true + shift + ;; -l | --list ) listnotes exit