feature(HELPERSCRIPTS): add text formatting functions

This commit is contained in:
Asif Bacchus 2021-01-15 05:47:00 -07:00
parent cb794e755f
commit 0a99c75a91

View File

@ -23,19 +23,35 @@ okNotify() {
printf "%s[OK]%s\n" "$ok" "$norm" printf "%s[OK]%s\n" "$ok" "$norm"
} }
textblock() {
printf "%s\n" "$1" | fold -w "$width" -s
}
textblockHeader() {
printf "\n%s***%s***%s\n" "$header" "$1" "$norm"
}
textblockParam() {
printf "%s%s%s\n" "$info" "$1" "$norm"
}
### text formatting presets ### text formatting presets
if command -v tput >/dev/null 2>&1; then if command -v tput >/dev/null 2>&1; then
err=$(tput bold)$(tput setaf 1) err=$(tput bold)$(tput setaf 1)
info=$(tput bold)$(tput setaf 6) info=$(tput bold)$(tput setaf 6)
header=$(tput bold)$(tput setaf 5)
norm=$(tput sgr0) norm=$(tput sgr0)
ok=$(tput sgr0)$(tput setaf 2) ok=$(tput sgr0)$(tput setaf 2)
warn=$(tput bold)$(tput setaf 3) warn=$(tput bold)$(tput setaf 3)
width=$(tput cols)
else else
err='' err=''
info='' info=''
header=''
norm='' norm=''
ok='' ok=''
warn='' warn=''
width=80
fi fi
### pre-requisites ### pre-requisites