fix: dialog allowed a higher option than actually possible

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus
2022-04-17 18:59:11 +02:00
parent 02d0ce8a78
commit f362cdce8f

View File

@@ -13,7 +13,7 @@ set -e
function change_klipper_repo_menu(){ function change_klipper_repo_menu(){
local repo_file="${SRCDIR}/kiauh/klipper_repos.txt" local repo_file="${SRCDIR}/kiauh/klipper_repos.txt"
local url branch i=0 local url branch
top_border top_border
echo -e "| ~~~~~~~~ [ Set custom Klipper repo ] ~~~~~~~~ | " echo -e "| ~~~~~~~~ [ Set custom Klipper repo ] ~~~~~~~~ | "
@@ -27,19 +27,12 @@ function change_klipper_repo_menu(){
while IFS="," read -r col1 col2; do while IFS="," read -r col1 col2; do
url+=("${col1}") url+=("${col1}")
branch+=("${col2}") branch+=("${col2}")
i=$((i+1)) done < <(grep "" "${repo_file}" | tail -n "+11")
done < <(grep "" "${repo_file}" | tail -n "+12")
while true; do while true; do
read -p "${cyan}Select Klipper repo:${white} " option read -p "${cyan}Perform action:${white} " option
if [ "${option}" = "b" ] || [ "${option}" = "B" ]; then case "${option}" in
clear && print_header 0 | "$((option < ${#url[@]}))")
settings_menu
break
elif [ "${option}" = "h" ] || [ "${option}" = "H" ]; then
clear && print_header
show_custom_klipper_repo_help
elif [ "${option}" -le ${#url[@]} ]; then
if [ -d "${KLIPPER_DIR}" ]; then if [ -d "${KLIPPER_DIR}" ]; then
top_border top_border
echo -e "| ${red}!!! ATTENTION !!!${white} |" echo -e "| ${red}!!! ATTENTION !!!${white} |"
@@ -67,12 +60,18 @@ function change_klipper_repo_menu(){
set_custom_klipper_repo "${url[${option}]}" "${branch[${option}]}" set_custom_klipper_repo "${url[${option}]}" "${branch[${option}]}"
ok_msg "This repo will now be used for new Klipper installations!\n" ok_msg "This repo will now be used for new Klipper installations!\n"
fi fi
break break;;
else B|b)
clear && print_header clear && print_header
print_error "Invalid command!" settings_menu
change_klipper_repo_menu break;;
fi H|h)
clear && print_header
show_custom_klipper_repo_help
break;;
*)
error_msg "Invalid command!";;
esac
done done
} }
@@ -95,9 +94,10 @@ function switch_klipper_repo(){
url=${1} branch=${2} url=${1} branch=${2}
status_msg "Switching Klipper repository..." status_msg "Switching Klipper repository..."
do_action_service "stop" "klipper" do_action_service "stop" "klipper"
cd ~ && rm -rf "${KLIPPER_DIR}" cd "${HOME}"
git clone "${url}" && cd "${KLIPPER_DIR}" [ -d "${KLIPPER_DIR}" ] && rm -rf "${KLIPPER_DIR}"
git checkout "${branch}" && cd ~ git clone "${url}" "klipper" && cd "${KLIPPER_DIR}"
git checkout "${branch}" && cd "${HOME}"
do_action_service "start" "klipper" do_action_service "start" "klipper"
} }