From bd1ad48f5669d547641131b2d8c0c48acbc9b278 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Thu, 17 Feb 2022 00:41:24 -0300 Subject: [PATCH] Add printHelp() --- scripts/common.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/common.sh b/scripts/common.sh index 57cf9a2..67f80fc 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -79,6 +79,14 @@ printLine() { printf '\n\n%s' "----------------------------------------" } +printHelp() { + tput bold + tput setaf 3 + printf '\n\n%s' "$1" + tput sgr0 + printf '\n%s' "----------------------------------------" +} + usePlainText() { if [ "$1" = "--menu" ]; then usePlainTextMenu "$@" @@ -154,11 +162,7 @@ usePlainTextMenu() { usePlainTextList() { clear tput bold - shift - msg="${1:2} To select an element you must enter its number" - msg="${msg} (which appears to the left of the element)." - msg="${msg} Also, you can deselect an item by re-entering its number." - printf '%s\n' "$msg"; shift; shift + shift; msg="${1:2}"; printf '%s\n' "$msg"; shift; shift tput sgr0 options=() local i=2; j=0; for item in "$@"; do @@ -170,7 +174,9 @@ usePlainTextList() { ((i++)) done - printLine + helpmsg="To select an element you must enter its number." + helpmsg="${helpmsg} Also, you can deselect an item by re-entering its number." + printHelp "$helpmsg" printf '\n%s' "[1..$j] " isNewline=false selectedOptions=() @@ -206,7 +212,8 @@ usePlainTextList() { fi ((i++)) done - printLine + # printLine + printHelp "$helpmsg" printf '\n%s' "[1..$j] " done printf "\n"