mirror of
https://github.com/csunny/DB-GPT.git
synced 2026-07-16 17:15:22 +00:00
docs: install and readme (#2991)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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]$ ]]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user