fix(switch_klipper_repo): use of case didn't allow selections of 2 and above

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
th33xitus
2022-09-10 20:25:05 +02:00
parent f25726cfed
commit 9d90daec7f

View File

@@ -43,53 +43,57 @@ function change_klipper_repo_menu() {
back_help_footer back_help_footer
local option local option
local num="^[0-9]+$"
local back="^(B|b)$"
local help="^(H|h)$"
while true; do while true; do
read -p "${cyan}###### Perform action:${white} " option read -p "${cyan}###### Perform action:${white} " option
case "${option}" in
0 | "$(( option < ${#repos[@]} ))")
select_msg "Repo: ${repos[option]} Branch: ${branches[option]}"
if [[ -d ${KLIPPER_DIR} ]]; then
top_border
echo -e "| ${red}!!! ATTENTION !!!${white} |"
echo -e "| Existing Klipper folder found! Proceeding will remove | "
echo -e "| the existing Klipper folder and replace it with a | "
echo -e "| clean copy of the previously selected source repo! | "
bottom_border
local yn if [[ ${option} =~ ${num} && ${option} -lt ${#repos[@]} ]]; then
while true; do select_msg "Repo: ${repos[option]} Branch: ${branches[option]}"
read -p "${cyan}###### Proceed? (Y/n):${white} " yn
case "${yn}" in if [[ -d ${KLIPPER_DIR} ]]; then
Y|y|Yes|yes|"") top_border
select_msg "Yes" echo -e "| ${red}!!! ATTENTION !!!${white} |"
switch_klipper_repo "${repos[${option}]}" "${branches[${option}]}" echo -e "| Existing Klipper folder found! Proceeding will remove | "
set_custom_klipper_repo "${repos[${option}]}" "${branches[${option}]}" echo -e "| the existing Klipper folder and replace it with a | "
break;; echo -e "| clean copy of the previously selected source repo! | "
N|n|No|no) bottom_border
select_msg "No"
break;; local yn
*) while true; do
error_msg "Invalid command!";; read -p "${cyan}###### Proceed? (Y/n):${white} " yn
esac case "${yn}" in
done Y|y|Yes|yes|"")
else select_msg "Yes"
status_msg "Set custom Klipper repository to:\n ● Repository: ${repos[${option}]}\n ● Branch: ${branches[${option}]}" switch_klipper_repo "${repos[${option}]}" "${branches[${option}]}"
set_custom_klipper_repo "${repos[${option}]}" "${branches[${option}]}" set_custom_klipper_repo "${repos[${option}]}" "${branches[${option}]}"
ok_msg "This repo will now be used for new Klipper installations!\n" break;;
fi N|n|No|no)
break;; select_msg "No"
B|b) break;;
clear && print_header *)
settings_menu error_msg "Invalid command!";;
break;; esac
H|h) done
clear && print_header else
show_custom_klipper_repo_help status_msg "Set custom Klipper repository to:\n ● Repository: ${repos[${option}]}\n ● Branch: ${branches[${option}]}"
break;; set_custom_klipper_repo "${repos[${option}]}" "${branches[${option}]}"
*) ok_msg "This repo will now be used for new Klipper installations!\n"
error_msg "Invalid command!";; fi
esac
elif [[ ${option} =~ ${back} ]]; then
clear && print_header
settings_menu
elif [[ ${option} =~ ${help} ]]; then
clear && print_header
show_custom_klipper_repo_help
else
error_msg "Invalid command!"
fi
done done
change_klipper_repo_menu change_klipper_repo_menu
} }