summaryrefslogtreecommitdiff
path: root/apps/installer/main.sh
diff options
context:
space:
mode:
authorYehonal <yehonal.azeroth@gmail.com>2025-09-04 00:03:55 +0200
committerGitHub <noreply@github.com>2025-09-04 00:03:55 +0200
commit599d206584f801adf3e42fede6bf0496605b60c3 (patch)
treea8a5f3e49fa250941395e91641fe15dea2c24ba4 /apps/installer/main.sh
parentd5d8256bc5f733477966f70d0802abdedde0cd2d (diff)
feat(MenuSystem): Implement unified menu system for AzerothCore management (#22786)
Diffstat (limited to 'apps/installer/main.sh')
-rw-r--r--apps/installer/main.sh169
1 files changed, 81 insertions, 88 deletions
diff --git a/apps/installer/main.sh b/apps/installer/main.sh
index 5911ccbf74..3bdd99b225 100644
--- a/apps/installer/main.sh
+++ b/apps/installer/main.sh
@@ -1,114 +1,107 @@
#!/usr/bin/env bash
-CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+# AzerothCore Dashboard Script
+#
+# This script provides an interactive menu system for AzerothCore management
+# using the unified menu system library.
+#
+# Usage:
+# ./acore.sh - Interactive mode with numeric and text selection
+# ./acore.sh <command> [args] - Direct command execution (only text commands, no numbers)
+#
+# Interactive Mode:
+# - Select options by number (1, 2, 3...), command name (init, compiler, etc.),
+# or short alias (i, c, etc.)
+# - All selection methods work in interactive mode
+#
+# Direct Command Mode:
+# - Only command names and short aliases are accepted (e.g., './acore.sh compiler build', './acore.sh c build')
+# - Numeric selection is disabled to prevent confusion with command arguments
+# - Examples: './acore.sh init', './acore.sh compiler clean', './acore.sh module install mod-name'
+#
+# Menu System:
+# - Uses unified menu system from bash_shared/menu_system.sh
+# - Single source of truth for menu definitions
+# - Consistent behavior across all AzerothCore tools
+CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/includes/includes.sh"
+source "$AC_PATH_APPS/bash_shared/menu_system.sh"
-PS3='[Please enter your choice]: '
-options=(
- "init (i): First Installation"
- "install-deps (d): Configure OS dep"
- "pull (u): Update Repository"
- "reset (r): Reset & Clean Repository"
- "compiler (c): Run compiler tool"
- "module (m): Module manager (search/install/update/remove)"
- "module-install (mi): Module Install by name [DEPRECATED]"
- "module-update (mu): Module Update by name [DEPRECATED]"
- "module-remove: (mr): Module Remove by name [DEPRECATED]"
- "client-data: (gd): download client data from github repository (beta)"
- "run-worldserver (rw): execute a simple restarter for worldserver"
- "run-authserver (ra): execute a simple restarter for authserver"
- "docker (dr): Run docker tools"
- "version (v): Show AzerothCore version"
- "service-manager (sm): Run service manager to run authserver and worldserver in background"
- "quit (q): Exit from this menu"
- )
+# Menu: single ordered source of truth (no functions in strings)
+# Format: "key|short|description"
+menu_items=(
+ "init|i|First Installation"
+ "install-deps|d|Configure OS dep"
+ "pull|u|Update Repository"
+ "reset|r|Reset & Clean Repository"
+ "compiler|c|Run compiler tool"
+ "module|m|Module manager (search/install/update/remove)"
+ "client-data|gd|download client data from github repository (beta)"
+ "run-worldserver|rw|execute a simple restarter for worldserver"
+ "run-authserver|ra|execute a simple restarter for authserver"
+ "docker|dr|Run docker tools"
+ "version|v|Show AzerothCore version"
+ "service-manager|sm|Run service manager to run authserver and worldserver in background"
+ "quit|q|Exit from this menu"
+)
-function _switch() {
- _reply="$1"
- _opt="$2"
- case $_reply in
- ""|"i"|"init")
- inst_allInOne
- ;;
- ""|"d"|"install-deps")
- inst_configureOS
- ;;
- ""|"u"|"pull")
- inst_updateRepo
+# Menu command handler - called by menu system for each command
+function handle_menu_command() {
+ local key="$1"
+ shift
+
+ case "$key" in
+ "init")
+ inst_allInOne
;;
- ""|"r"|"reset")
- inst_resetRepo
+ "install-deps")
+ inst_configureOS
;;
- ""|"c"|"compiler")
- bash "$AC_PATH_APPS/compiler/compiler.sh" $_opt
+ "pull")
+ inst_updateRepo
;;
- ""|"m"|"module")
- # Unified module command: supports subcommands search|install|update|remove
- inst_module "${@:2}"
+ "reset")
+ inst_resetRepo
;;
- ""|"ms"|"module-search")
- echo "[DEPRECATED] Use: ./acore.sh module search <terms...>"
- inst_module_search "${@:2}"
+ "compiler")
+ bash "$AC_PATH_APPS/compiler/compiler.sh" "$@"
;;
- ""|"mi"|"module-install")
- echo "[DEPRECATED] Use: ./acore.sh module install <modules...>"
- inst_module_install "${@:2}"
+ "module")
+ bash "$AC_PATH_APPS/installer/includes/modules-manager/module-main.sh" "$@"
;;
- ""|"mu"|"module-update")
- echo "[DEPRECATED] Use: ./acore.sh module update <modules...>"
- inst_module_update "${@:2}"
+ "client-data")
+ inst_download_client_data
;;
- ""|"mr"|"module-remove")
- echo "[DEPRECATED] Use: ./acore.sh module remove <modules...>"
- inst_module_remove "${@:2}"
+ "run-worldserver")
+ inst_simple_restarter worldserver
;;
- ""|"gd"|"client-data")
- inst_download_client_data
+ "run-authserver")
+ inst_simple_restarter authserver
;;
- ""|"rw"|"run-worldserver")
- inst_simple_restarter worldserver
+ "docker")
+ DOCKER=1 bash "$AC_PATH_ROOT/apps/docker/docker-cmd.sh" "$@"
+ exit
;;
- ""|"ra"|"run-authserver")
- inst_simple_restarter authserver
- ;;
- ""|"dr"|"docker")
- DOCKER=1 bash "$AC_PATH_ROOT/apps/docker/docker-cmd.sh" "${@:2}"
- exit
- ;;
- ""|"v"|"version")
- # denoRunFile "$AC_PATH_APPS/installer/main.ts" "version"
+ "version")
printf "AzerothCore Rev. %s\n" "$ACORE_VERSION"
- exit
+ exit
;;
- ""|"sm"|"service-manager")
- bash "$AC_PATH_APPS/startup-scripts/src/service-manager.sh" "${@:2}"
- exit
+ "service-manager")
+ bash "$AC_PATH_APPS/startup-scripts/src/service-manager.sh" "$@"
+ exit
;;
- ""|"q"|"quit")
+ "quit")
echo "Goodbye!"
- exit
+ exit
;;
- ""|"--help")
- echo "Available commands:"
- printf '%s\n' "${options[@]}"
+ *)
+ echo "Invalid option. Use --help to see available commands."
+ return 1
;;
- *) echo "invalid option, use --help option for the commands list";;
esac
}
-while true
-do
- # run option directly if specified in argument
- [ ! -z $1 ] && _switch $@ # old method: "${options[$cmdopt-1]}"
- [ ! -z $1 ] && exit 0
-
- echo "==== ACORE DASHBOARD ===="
- select opt in "${options[@]}"
- do
- _switch $REPLY
- break
- done
- echo "opt: $opt"
-done
+# Run the menu system
+menu_run "ACORE DASHBOARD" handle_menu_command "${menu_items[@]}" "$@"