Add printHelp()

This commit is contained in:
Santiago Lo Coco 2022-02-17 00:41:24 -03:00
parent cc0ea0a113
commit bd1ad48f56
1 changed files with 14 additions and 7 deletions

View File

@ -79,6 +79,14 @@ printLine() {
printf '\n\n%s' "----------------------------------------" printf '\n\n%s' "----------------------------------------"
} }
printHelp() {
tput bold
tput setaf 3
printf '\n\n%s' "$1"
tput sgr0
printf '\n%s' "----------------------------------------"
}
usePlainText() { usePlainText() {
if [ "$1" = "--menu" ]; then if [ "$1" = "--menu" ]; then
usePlainTextMenu "$@" usePlainTextMenu "$@"
@ -154,11 +162,7 @@ usePlainTextMenu() {
usePlainTextList() { usePlainTextList() {
clear clear
tput bold tput bold
shift shift; msg="${1:2}"; printf '%s\n' "$msg"; shift; 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
tput sgr0 tput sgr0
options=() options=()
local i=2; j=0; for item in "$@"; do local i=2; j=0; for item in "$@"; do
@ -170,7 +174,9 @@ usePlainTextList() {
((i++)) ((i++))
done 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] " printf '\n%s' "[1..$j] "
isNewline=false isNewline=false
selectedOptions=() selectedOptions=()
@ -206,7 +212,8 @@ usePlainTextList() {
fi fi
((i++)) ((i++))
done done
printLine # printLine
printHelp "$helpmsg"
printf '\n%s' "[1..$j] " printf '\n%s' "[1..$j] "
done done
printf "\n" printf "\n"