41 lines
1 KiB
Bash
41 lines
1 KiB
Bash
|
# -*- mode: bash -*-
|
||
|
# shellcheck disable=SC2059
|
||
|
|
||
|
[[ ! "${LIB_SHELL_INTERACTION}" ]] && LIB_SHELL_INTERACTION="Y" || return
|
||
|
|
||
|
SYMBOL_SUCCESS="✔"
|
||
|
SYMBOL_FAILURE="✘"
|
||
|
SYMBOL_ARROW="➜"
|
||
|
|
||
|
COLOR_NORMAL="\\e[00m"
|
||
|
|
||
|
# check if stdout is a tty so we can use color code
|
||
|
if [[ -t 1 ]]; then
|
||
|
SH_LIB_PREFIX_WARN="[ \\[\\e[01;33m\\]WARN\\[\\e[00;00m\\] ] "
|
||
|
SH_LIB_PREFIX_INFO="[ \\[\\e[01;34m\\]INFO\\[\\e[00;00m\\] ] "
|
||
|
SH_LIB_PREFIX_SUCCESS="[ \\[\\e[01;31m\\]FAILURE\\[\\e[00;00m\\] ] "
|
||
|
SH_LIB_PREFIX_FAILURE="[ \\[\\e[01;32m\\]SUCCESS\\[\\e[00;00m\\] ] "
|
||
|
fi
|
||
|
|
||
|
function @warn() {
|
||
|
local format="${1:?"require format"}" && shift
|
||
|
printf "${SH_LIB_PREFIX_WARN@P}${format}\n" "${@}"
|
||
|
}
|
||
|
|
||
|
function @info() {
|
||
|
local format="${1:?"require format"}" && shift
|
||
|
printf "${SH_LIB_PREFIX_INFO@P}${format}\n" "${@}"
|
||
|
}
|
||
|
|
||
|
function @success() {
|
||
|
local format="${1:?"require format"}" && shift
|
||
|
printf "${SH_LIB_PREFIX_SUCCESS@P}${format}\n" "${@}"
|
||
|
}
|
||
|
|
||
|
function @failure() {
|
||
|
local format="${1:?"require format"}" && shift
|
||
|
printf "${SH_LIB_PREFIX_FAILURE@P}${format}\n" "${@}"
|
||
|
}
|
||
|
|
||
|
➜
|
||
|
# ➜
|