2
This commit is contained in:
@@ -45,7 +45,7 @@ prompt_confirm_default() {
|
||||
local answer=""
|
||||
local prompt_suffix="[y/N]"
|
||||
|
||||
if [[ "$default_answer" =~ ^[Yy]$ ]]; then
|
||||
if [[ "$default_answer" =~ ^([Yy]|yes|YES|Yes)$ ]]; then
|
||||
prompt_suffix="[Y/n]"
|
||||
fi
|
||||
|
||||
@@ -76,7 +76,31 @@ prompt_select_from_list() {
|
||||
local selection=""
|
||||
|
||||
for selection in "${options[@]}"; do
|
||||
printf ' %d. %s\n' "$index" "$selection"
|
||||
printf ' %d. %s\n' "$index" "$selection" >&2
|
||||
index=$((index + 1))
|
||||
done
|
||||
|
||||
selection="$(prompt_select_number "$label" 1 "${#options[@]}")"
|
||||
printf '%s\n' "${options[$((selection - 1))]}"
|
||||
}
|
||||
|
||||
prompt_select_described_from_list() {
|
||||
local label="$1"
|
||||
shift
|
||||
local entries=("$@")
|
||||
local entry=""
|
||||
local option=""
|
||||
local description=""
|
||||
local options=()
|
||||
local index=1
|
||||
local selection=""
|
||||
|
||||
for entry in "${entries[@]}"; do
|
||||
option="${entry%%|*}"
|
||||
description="${entry#*|}"
|
||||
options+=("$option")
|
||||
printf ' %d. %s\n' "$index" "$option" >&2
|
||||
printf ' %s\n' "$description" >&2
|
||||
index=$((index + 1))
|
||||
done
|
||||
|
||||
@@ -99,7 +123,7 @@ prompt_select_multiple_from_list() {
|
||||
IFS=$'\n' read -r -d '' -a labels < <(printf '%s\0' "$labels_csv")
|
||||
|
||||
for raw_index in "${labels[@]}"; do
|
||||
printf ' %d. %s\n' "$index" "$raw_index"
|
||||
printf ' %d. %s\n' "$index" "$raw_index" >&2
|
||||
index=$((index + 1))
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user