docs: install and readme (#2991)

This commit is contained in:
Aries-ckt
2026-03-16 15:15:47 +08:00
committed by GitHub
parent ef83851b31
commit aec6673b1a
8 changed files with 136 additions and 35 deletions

View File

@@ -218,7 +218,7 @@ step_choose_profile() {
printf '\n'
local choice
read -r -p "Enter choice [1]: " choice
prompt_input "Enter choice [1]: " choice
choice="${choice:-1}"
case "${choice}" in

View File

@@ -27,6 +27,27 @@ success() {
printf "${COLOR_GREEN}[OK]${COLOR_RESET} %s\n" "$*"
}
prompt_input() {
local prompt="$1"
local __resultvar="$2"
local answer=""
if [[ -r /dev/tty ]]; then
if read -r -p "${prompt}" answer < /dev/tty 2>/dev/null; then
printf -v "${__resultvar}" '%s' "${answer}"
return
fi
fi
if [[ -t 0 ]]; then
read -r -p "${prompt}" answer || die "Failed to read input from stdin."
else
die "Interactive input requires a terminal. Re-run with explicit flags such as --profile <name> or --yes."
fi
printf -v "${__resultvar}" '%s' "${answer}"
}
die() {
error "$*"
exit 1
@@ -63,7 +84,7 @@ confirm() {
fi
local answer
read -r -p "${prompt} [y/N]: " answer
prompt_input "${prompt} [y/N]: " answer
[[ "${answer}" =~ ^[Yy]$ ]]
}