fix: validate user input for amount of Klipper instances to install

This commit is contained in:
th33xitus
2021-05-23 10:44:51 +02:00
parent 87f229c62d
commit fb0a30814d

View File

@@ -18,19 +18,19 @@ klipper_setup_dialog(){
check_klipper_cfg_path check_klipper_cfg_path
### ask for amount of instances to create ### ask for amount of instances to create
while true; do INSTANCE_COUNT=""
while [[ ! ($INSTANCE_COUNT =~ ^[1-9]+$) ]]; do
echo echo
read -p "${cyan}###### How many Klipper instances do you want to set up?:${default} " INSTANCE_COUNT read -p "${cyan}###### Amount of Klipper instances to set up:${default} " INSTANCE_COUNT
echo if [[ ! ($INSTANCE_COUNT =~ ^[1-9]+$) ]]; then
if [ $INSTANCE_COUNT == 1 ]; then warn_msg "Invalid Input!" && echo
read -p "${cyan}###### Create $INSTANCE_COUNT single instance? (Y/n):${default} " yn
else else
read -p "${cyan}###### Create $INSTANCE_COUNT instances? (Y/n):${default} " yn echo
fi read -p "${cyan}###### Install $INSTANCE_COUNT instance(s)? (Y/n):${default} " yn
case "$yn" in case "$yn" in
Y|y|Yes|yes|"") Y|y|Yes|yes|"")
echo -e "###### > Yes" echo -e "###### > Yes"
status_msg "Creating $INSTANCE_COUNT Klipper instances ..." status_msg "Installing $INSTANCE_COUNT Klipper instance(s) ..."
klipper_setup klipper_setup
break;; break;;
N|n|No|no) N|n|No|no)
@@ -42,6 +42,7 @@ klipper_setup_dialog(){
print_unkown_cmd print_unkown_cmd
print_msg && clear_msg;; print_msg && clear_msg;;
esac esac
fi
done done
} }