first
This commit is contained in:
101
menus/main.sh
Normal file
101
menus/main.sh
Normal file
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
menu_modules_by_prefix() {
|
||||
local prefix="$1"
|
||||
local title="$2"
|
||||
local matching_modules=()
|
||||
local module_id=""
|
||||
local selection=""
|
||||
local index=1
|
||||
|
||||
while IFS= read -r module_id; do
|
||||
[[ "$module_id" == "$prefix"/* ]] || continue
|
||||
matching_modules+=("$module_id")
|
||||
done < <(registry_list)
|
||||
|
||||
if [[ "${#matching_modules[@]}" -eq 0 ]]; then
|
||||
ui_warn "Aucun module disponible pour $title"
|
||||
ui_pause
|
||||
return 0
|
||||
fi
|
||||
|
||||
ui_section "$title"
|
||||
for module_id in "${matching_modules[@]}"; do
|
||||
printf ' %d. %s\n' "$index" "$module_id"
|
||||
index=$((index + 1))
|
||||
done
|
||||
printf ' 0. Retour\n'
|
||||
|
||||
selection="$(prompt_select_number "Selectionner un module" 0 "${#matching_modules[@]}")"
|
||||
if [[ "$selection" == "0" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
dispatcher_prompt_and_run_module "${matching_modules[$((selection - 1))]}"
|
||||
ui_pause
|
||||
}
|
||||
|
||||
menu_category_selection() {
|
||||
local categories=("network" "containers" "boot" "hardware")
|
||||
local selection=""
|
||||
|
||||
ui_section "Installation par categorie"
|
||||
printf ' 1. network\n'
|
||||
printf ' 2. containers\n'
|
||||
printf ' 3. boot\n'
|
||||
printf ' 4. hardware\n'
|
||||
printf ' 0. Retour\n'
|
||||
|
||||
selection="$(prompt_select_number "Selectionner une categorie" 0 4)"
|
||||
case "$selection" in
|
||||
0) return 0 ;;
|
||||
1) menu_modules_by_prefix "network" "Configuration reseau" ;;
|
||||
2) menu_modules_by_prefix "containers" "Conteneurs" ;;
|
||||
3) menu_modules_by_prefix "boot" "Configuration du boot" ;;
|
||||
4) menu_modules_by_prefix "hardware" "Materiel" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
menu_system_configuration() {
|
||||
menu_modules_by_prefix "system" "Configuration systeme"
|
||||
}
|
||||
|
||||
menu_main() {
|
||||
local selection=""
|
||||
|
||||
while true; do
|
||||
ui_menu \
|
||||
"Menu principal" \
|
||||
"1. Installation par categorie" \
|
||||
"2. Installation par profil" \
|
||||
"3. Installation par materiel" \
|
||||
"4. Configuration systeme" \
|
||||
"5. Tests" \
|
||||
"0. Quitter"
|
||||
|
||||
ui_info "Modules detectes : $(registry_summary)"
|
||||
ui_info "Log : $RUNTIME_LOG_FILE"
|
||||
|
||||
selection="$(prompt_select_number "Choisir une action" 0 5)"
|
||||
|
||||
case "$selection" in
|
||||
0)
|
||||
ui_info "Sortie du programme"
|
||||
return 0
|
||||
;;
|
||||
1)
|
||||
menu_category_selection
|
||||
;;
|
||||
3)
|
||||
menu_modules_by_prefix "hardware" "Materiel"
|
||||
;;
|
||||
4)
|
||||
menu_system_configuration
|
||||
;;
|
||||
*)
|
||||
dispatcher_not_implemented "menu $selection"
|
||||
ui_pause
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
Reference in New Issue
Block a user