Изменил(а) на 'shell/helpers.sh'

This commit is contained in:
Anthony Axenov 2023-07-10 10:47:25 +00:00
parent 566424b15b
commit e384d15d4b

View File

@ -234,48 +234,48 @@ print() {
debug() {
if [ "$2" ]; then
print "${DIM}${BOLD}${RESET}${DIM} ${FUNCNAME[1]:-?}():${BASH_LINENO:-?}\t$1 "
print "${DIM}${BOLD}${RESET}${DIM}$(dt)${IDEBUG} ${FUNCNAME[1]:-?}():${BASH_LINENO:-?}\t$1 " >&2
else
print "${DIM}${BOLD}${RESET}${DIM}$1 "
print "${DIM}${BOLD}${RESET}${DIM}$(dt)${IDEBUG} $1 " >&2
fi
}
var_dump() {
debug "$1 = ${!1}" 0
debug "$1 = ${!1}"
}
verbose() {
print "${BOLD}${IVRB}${RESET}${FYELLOW} $1 "
print "${BOLD}$(dt)${IVRB}${RESET}${FYELLOW} $1 "
}
info() {
print "${BOLD}${FWHITE}${BLBLUE}${IINFO}${RESET}${FWHITE} $1 "
print "${BOLD}$(dt)${FWHITE}${BLBLUE}${IINFO}${RESET}${FWHITE} $1 "
}
note() {
print "${BOLD}${DIM}${FWHITE}${INOTE}${RESET} $1 "
print "${BOLD}$(dt)${DIM}${FWHITE}${INOTE}${RESET} $1 "
}
success() {
print "${BOLD}${BGREEN}${FWHITE}${ISUCCESS}${BRESET}$FGREEN $1 "
print "${BOLD}$(dt)${BGREEN}${FWHITE}${ISUCCESS}${BRESET}$FGREEN $1 "
}
warn() {
print "${BOLD}${BYELLOW}${FBLACK}${IWARN}${BRESET}${FYELLOW} Warning:${RESET} $1 "
print "${BOLD}$(dt)${BYELLOW}${FBLACK}${IWARN}${BRESET}${FYELLOW} Warning:${RESET} $1 "
}
error() {
print "${BOLD}${BLRED}${FWHITE}${IERROR} Error: ${BRESET}${FLRED} $1 " >&2
print "${BOLD}$(dt)${BLRED}${FWHITE}${IERROR} Error: ${BRESET}${FLRED} $1 " >&2
}
fatal() {
print "${BOLD}${BRED}${FWHITE}${IFATAL} FATAL: $1 " >&2
print "${BOLD}$(dt)${BRED}${FWHITE}${IFATAL} FATAL: $1 " >&2
print_stacktrace
}
die() {
error "${1:-halted}"
exit ${2:-100}
exit ${2:-255}
}
print_stacktrace() {
@ -294,6 +294,18 @@ print_stacktrace() {
done
}
# var='test var_dump'
# var_dump var
# debug 'test debug'
# verbose 'test verbose'
# info 'test info'
# note 'test note'
# success 'test success'
# warn 'test warn'
# error 'test error'
# fatal 'test fatal'
# die 'test die'
########################################################
# Tests
########################################################