Изменил(а) на 'shell/helpers.sh'
This commit is contained in:
parent
566424b15b
commit
e384d15d4b
@ -224,8 +224,8 @@ dt() {
|
||||
echo "[$(date +'%H:%M:%S')] "
|
||||
}
|
||||
|
||||
ask() {
|
||||
IFS= read -rp "$(print ${BOLD}${BBLUE}${FWHITE}${IASK}${BRESET}\ ${BOLD}$1 ): " $2
|
||||
ask() {
|
||||
IFS= read -rp "$(print ${BOLD}${BBLUE}${FWHITE}${IASK}${BRESET}\ ${BOLD}$1 ): " $2
|
||||
}
|
||||
|
||||
print() {
|
||||
@ -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
|
||||
########################################################
|
||||
@ -609,4 +621,4 @@ git.require_clean_worktree() {
|
||||
# https://gitlab.com/kyb/autorsync/-/blob/master/
|
||||
# https://lug.fh-swf.de/vim/vim-bash/StyleGuideShell.en.pdf
|
||||
# https://www.thegeekstuff.com/2010/06/bash-array-tutorial/
|
||||
# https://www.distributednetworks.com/linux-network-admin/module4/ephemeral-reserved-portNumbers.php
|
||||
# https://www.distributednetworks.com/linux-network-admin/module4/ephemeral-reserved-portNumbers.php
|
Loading…
Reference in New Issue
Block a user