update: add a test.sh for a demo of main menu and sub menus

This commit is contained in:
Yingjie Wang 2024-03-30 18:02:08 -04:00
parent c45f1362ed
commit 0657950327

60
test.sh Executable file
View File

@ -0,0 +1,60 @@
#!/bin/bash
# 确保安装 gum
# pacman -Sy gum
main_menu() {
while true; do
clear
# 使用 gum 或其他工具显示主菜单
option=$(gum choose "分区硬盘" "设置网络" "安装基本系统" "开始安装" "退出安装")
case $option in
"分区硬盘")
partition_disk
;;
"设置网络")
setup_network
;;
"安装基本系统")
install_base_system
;;
"开始安装")
start_installation
break
;;
"退出安装")
exit 0
;;
esac
done
}
partition_disk() {
echo "分区硬盘..."
# 这里添加分区逻辑
gum confirm "返回主菜单?" && return
}
setup_network() {
echo "设置网络..."
# 这里添加网络设置逻辑
gum confirm "返回主菜单?" && return
}
install_base_system() {
echo "安装基本系统..."
# 这里添加安装基本系统的逻辑
gum confirm "返回主菜单?" && return
}
start_installation() {
echo "开始安装..."
# 这里添加实际开始安装的逻辑
echo "安装完成。"
exit 0
}
# 主菜单
main_menu