Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/lib/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ Codes can be combined.

```
Font colors:
TXT_BLACK Black
TXT_RED Red
TXT_GREEN Green
TXT_YELLOW Yellow
TXT_BLUE Blue
TXT_PURPLE Magenta

Background colors:
BACK_YELLOW Yellow
BACK_BLUE Blue

Other:
Expand Down Expand Up @@ -170,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
```
16 changes: 15 additions & 1 deletion lib/ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##
Expand Down Expand Up @@ -114,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
Expand Down