refactor: multiple

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus
2022-04-18 10:53:11 +02:00
parent 2406df702b
commit e6df33c518
15 changed files with 270 additions and 299 deletions

View File

@@ -11,7 +11,7 @@
set -e
advanced_ui(){
function advanced_ui(){
top_border
echo -e "| ${yellow}~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~${white} | "
hr
@@ -23,10 +23,10 @@ advanced_ui(){
echo -e "| 3) [Flash only] | | "
echo -e "| 4) [Build + Flash] | Extras: | "
echo -e "| 5) [Get MCU ID] | 8) [G-Code Shell Command] | "
back_footer
back_footer
}
advanced_menu(){
function advanced_menu(){
do_action "" "advanced_ui"
while true; do
read -p "${cyan}Perform action:${white} " action; echo

View File

@@ -11,7 +11,7 @@
set -e
backup_ui(){
function backup_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Backup Menu ] ~~~~~~~~~~~~~~") | "
hr
@@ -30,11 +30,11 @@ backup_ui(){
back_footer
}
backup_menu(){
function backup_menu(){
do_action "" "backup_ui"
while true; do
read -p "${cyan}Perform action:${white} " action; echo
case "$action" in
case "${action}" in
0)
do_action "backup_klipper_config_dir" "backup_ui";;
1)

View File

@@ -12,41 +12,41 @@
set -e
#ui total width = 57 chars
top_border(){
function top_border(){
echo -e "/=======================================================\\"
}
bottom_border(){
function bottom_border(){
echo -e "\=======================================================/"
}
blank_line(){
function blank_line(){
echo -e "| |"
}
hr(){
function hr(){
echo -e "|-------------------------------------------------------|"
}
quit_footer(){
function quit_footer(){
hr
echo -e "| ${red}Q) Quit${white} |"
bottom_border
}
back_footer(){
function back_footer(){
hr
echo -e "| ${green}B) « Back${white} |"
bottom_border
}
back_help_footer(){
function back_help_footer(){
hr
echo -e "| ${green}B) « Back${white} | ${yellow}H) Help [?]${white} |"
bottom_border
}
print_header(){
function print_header(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~ [ KIAUH ] ~~~~~~~~~~~~~~~~~") |"
echo -e "| $(title_msg " Klipper Installation And Update Helper ") |"
@@ -54,12 +54,7 @@ print_header(){
bottom_border
}
################################################################################
#******************************************************************************#
################################################################################
### TODO: rework other menus to make use of the following functions too and make them more readable
do_action(){
function do_action(){
clear && print_header
### $1 is the action the user wants to fire
$1
@@ -68,7 +63,7 @@ do_action(){
$2
}
deny_action(){
function deny_action(){
clear && print_header
print_error "Invalid command!"
$1

View File

@@ -11,7 +11,7 @@
set -e
main_ui(){
function main_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
hr
@@ -29,14 +29,14 @@ main_ui(){
quit_footer
}
get_kiauh_version(){
function get_kiauh_version(){
local version
cd "${SRCDIR}/kiauh"
version="$(printf "%-20s" "$(git describe HEAD --always --tags | cut -d "-" -f 1,2)")"
echo "${cyan}${version}${white}"
}
kiauh_update_dialog(){
function kiauh_update_dialog(){
[ ! "$(kiauh_update_avail)" == "true" ] && return
top_border
echo -e "|${green} New KIAUH update available! ${white}| "
@@ -60,7 +60,7 @@ kiauh_update_dialog(){
done
}
main_menu(){
function main_menu(){
print_header
#prompt for KIAUH update if update available
kiauh_update_dialog

View File

@@ -11,7 +11,7 @@
set -e
remove_ui(){
function remove_ui(){
top_border
echo -e "| ${red}~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~${white} | "
hr
@@ -30,7 +30,7 @@ remove_ui(){
back_footer
}
remove_menu(){
function remove_menu(){
do_action "" "remove_ui"
while true; do
read -p "${cyan}Perform action:${white} " action; echo

View File

@@ -117,7 +117,7 @@ function show_settings_help(){
done
}
settings_menu(){
function settings_menu(){
clear && print_header
settings_ui
while true; do
@@ -127,7 +127,7 @@ settings_menu(){
change_klipper_cfg_folder && settings_ui;;
2)
clear && print_header
change_klipper_repo_menu
change_klippefunction r_repo_menu
settings_ui;;
3)
switch_mainsail_releasetype && settings_menu;;

View File

@@ -11,8 +11,7 @@
set -e
update_ui(){
ui_print_versions
function update_ui(){
top_border
echo -e "| ${green}~~~~~~~~~~~~~~ [ Update Menu ] ~~~~~~~~~~~~~~${white} | "
hr
@@ -39,7 +38,8 @@ update_ui(){
back_footer
}
update_menu(){
function update_menu(){
unset update_arr
read_bb4u_stat
do_action "" "update_ui"
while true; do