From 41b3c2aa764b290434006d80a692b7b19e75db89 Mon Sep 17 00:00:00 2001 From: Sandor Semsey Date: Sun, 9 Jun 2024 15:02:06 +0200 Subject: [PATCH 1/2] lib/ui: add new color codes --- docs/lib/ui.md | 2 ++ lib/ui.sh | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/lib/ui.md b/docs/lib/ui.md index e1af507..20457de 100644 --- a/docs/lib/ui.md +++ b/docs/lib/ui.md @@ -17,6 +17,7 @@ Codes can be combined. ``` Font colors: +TXT_BLACK Black TXT_RED Red TXT_GREEN Green TXT_YELLOW Yellow @@ -24,6 +25,7 @@ TXT_BLUE Blue TXT_PURPLE Magenta Background colors: +BACK_YELLOW Yellow BACK_BLUE Blue Other: diff --git a/lib/ui.sh b/lib/ui.sh index 50de6ed..bf66fb5 100644 --- a/lib/ui.sh +++ b/lib/ui.sh @@ -11,24 +11,28 @@ TXT_NORM= TXT_BOLD= +TXT_BLACK= TXT_RED= TXT_GREEN= TXT_YELLOW= TXT_BLUE= TXT_PURPLE= +BACK_YELLOW= BACK_BLUE= if tput longname >/dev/null 2>&1; then TXT_NORM=$(tput sgr0) TXT_BOLD=$(tput bold) + TXT_BLACK=$(tput setaf 0) TXT_RED=$(tput setaf 1) TXT_GREEN=$(tput setaf 2) TXT_YELLOW=$(tput setaf 3) TXT_BLUE=$(tput setaf 4) TXT_PURPLE=$(tput setaf 5) + BACK_YELLOW=$(tput setab 3) BACK_BLUE=$(tput setab 4) fi -export TXT_NORM TXT_BOLD TXT_RED TXT_GREEN TXT_YELLOW TXT_BLUE TXT_PURPLE BACK_BLUE +export TXT_NORM TXT_BOLD TXT_BLACK TXT_RED TXT_GREEN TXT_YELLOW TXT_BLUE TXT_PURPLE BACK_YELLOW BACK_BLUE ############### ## FUNCTIONS ## From 1faa7839f5dc8690663c095c22e9588a374b8611 Mon Sep 17 00:00:00 2001 From: Sandor Semsey Date: Sun, 9 Jun 2024 15:10:29 +0200 Subject: [PATCH 2/2] lib/ui: print-warning --- docs/lib/ui.md | 15 +++++++++++++++ lib/ui.sh | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/docs/lib/ui.md b/docs/lib/ui.md index 20457de..002d65b 100644 --- a/docs/lib/ui.md +++ b/docs/lib/ui.md @@ -172,3 +172,18 @@ print-title TITLE Params: TITLE Title text ``` + +--- + +## print-warning + +Print warning message to stderr with yellow background. + +**Usage** + +``` +print-warning [MESSAGE] + +Params: +MESSAGE Warning message +``` diff --git a/lib/ui.sh b/lib/ui.sh index bf66fb5..7fc90ee 100644 --- a/lib/ui.sh +++ b/lib/ui.sh @@ -118,6 +118,16 @@ print-status() { echo -ne ${TXT_YELLOW}${*}${TXT_NORM} } +## Print warning message +## +## @param $* Message +######################## +print-warning() { + [[ -n "${ES_PRINT_HUSH:-}" ]] && return 0 + # shellcheck disable=SC2086 + echo -e ${BACK_YELLOW}${TXT_BLACK}${TXT_BOLD}${*}${TXT_NORM} >&2 +} + ## Print OK message ## ## @param $* Message