32 lines
899 B
Bash
Executable file
32 lines
899 B
Bash
Executable file
#!/bin/bash
|
|
ask_input() {
|
|
local label="$1"
|
|
local default="${2:-}"
|
|
local prompt_default=""
|
|
[ -n "$default" ] && prompt_default=" ${DIM}[${default}]${RESET}"
|
|
|
|
printf " ${BCYAN}?${RESET} ${BWHITE}%s${RESET}%b " "$label" "$prompt_default"
|
|
read -r INPUT_RESULT
|
|
[ -z "$INPUT_RESULT" ] && INPUT_RESULT="$default"
|
|
}
|
|
|
|
ask_confirm() {
|
|
local label="$1"
|
|
local default="${2:-y}"
|
|
local hint
|
|
if [ "$default" = "y" ]; then hint="${BGREEN}Y${RESET}${DIM}/n${RESET}"; else hint="${DIM}y/${RESET}${BRED}N${RESET}"; fi
|
|
|
|
printf " ${BYELLOW}?${RESET} ${BWHITE}%s${RESET} [%b] " "$label" "$hint"
|
|
read -r _confirm
|
|
_confirm="${_confirm:-$default}"
|
|
case "${_confirm,,}" in
|
|
y|yes) return 0 ;;
|
|
*) return 1 ;;
|
|
esac
|
|
}
|
|
|
|
ask_pause() {
|
|
local msg="${1:-Press ENTER to continue...}"
|
|
printf " ${DIM}%s${RESET}" "$msg"
|
|
read -r
|
|
}
|