Files
sig-installer/builtin/cli-minimal.bash
Christian Tosta e615c113f8 Initial import
2025-05-30 13:14:06 -03:00

56 lines
1.4 KiB
Bash
Executable File

export NO_FMT="\033[0m"
export F_BOLD="\033[1m"
export C_NONE="\033[0m"
export C_RED="\033[38;5;9m"
export C_BLUE="\033[38;5;12m"
export C_GREEN="\033[38;5;2m"
export C_ORANGE="\033[38;5;208m"
export C_GOLD="\033[38;5;220m"
export C_PURPLE="\033[38;5;5m"
export S_INFO="${C_BLUE}\u2691 [info] ${NO_FMT} "
export S_SUCCESS="${C_GREEN}\u2691 [success] ${NO_FMT}\u2713 "
export S_DEBUG="${C_PURPLE}\u2691 [debug]${NO_FMT} "
export S_WARN="${C_ORANGE}\u2691 [warning] ${NO_FMT} "
export S_ERROR="${C_RED}\u2691 [error] ${NO_FMT}\u2715 "
export U_ITEM="\u2192"
export COLS="$(( $(tput cols) - 1 ))"
cli.section() {
__section.header() {
__section.title() {
printf $"${@:1:1}" \
$(echo -ne ${F_BOLD}${C_BLUE}${@:2:1}${NO_FMT}) \
$(echo -ne ${C_ORANGE}${@:3}${NO_FMT})
}
__section.title.underline() {
for i in $(seq 1 ${COLS}); do \
printf "%s" $(echo -ne "\u2581"); \
done
}
__section.title "${@}"
__section.title.underline
}
__section.content() {
printf "%2s\n"
printf "%s" "${@}" | fold -sw ${COLS}
}
__section.footer() {
__section.footer.line() {
[ -z "${1:-}" ] && printf "%s\n"
for i in $(seq 1 ${COLS}); do \
printf "%s" $(echo -ne "\u2504${NO_FMT}"); \
done && \
[ -z "${1:-}" ] && printf "%2s\n"
}
__section.footer.line
}
__section.header "${@:1:3}"
__section.content "${@:4}"
__section.footer
}
cli.section "${@}"