From a2008cb0441847944032bb2d17e57c4f7110d2f3 Mon Sep 17 00:00:00 2001 From: Asainte Bueno-Villanueva Date: Fri, 6 Feb 2026 03:45:36 -0500 Subject: [PATCH] exit strategies --- core/dynr | 54 +++++++++++++++++++----------------------------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/core/dynr b/core/dynr index 30cc69d..b1b8447 100644 --- a/core/dynr +++ b/core/dynr @@ -1,19 +1,23 @@ #!/bin/bash # ----------------------------------------------------------------------- -# Dynasty Revolution CLI Framework (dynr) - DYNAMIC CORE v2.3.3 +# Dynasty Revolution CLI Framework (dynr) - DYNAMIC CORE v2.3.4 # Authors: Dynasty Revolution & SaavageBueno # ----------------------------------------------------------------------- -VERSION="2.3.3" +VERSION="2.3.4" BLUE='\033[38;5;45m'; PURPLE='\033[38;5;127m'; GOLD='\033[38;5;178m'; RED='\033[38;5;196m'; NC='\033[0m' REPO_RAW="https://git.dynastyrevolution.com/DYNR/DynastyRevolution-Scripts/raw/branch/main" MOD_DIR="/opt/dynr/modules" +# --- The Magic Loader --- load_and_run() { local mod=$1 local remote="$REPO_RAW/modules/$mod" + + # 1. Download if missing if [ ! -f "$MOD_DIR/$mod" ]; then echo -e "${GOLD}🐉 Seeking the '$mod' scroll in the archives...${NC}" + # -f fails silently on 404 to allow custom error handling if curl -sSLf "$remote" -o "$MOD_DIR/$mod"; then chmod +x "$MOD_DIR/$mod" else @@ -21,45 +25,25 @@ load_and_run() { return 1 fi fi + + # 2. Load the file source "$MOD_DIR/$mod" + + # 3. Execute: run_ (Converts hyphens to underscores for Bash functions) + # Example: 'system-info' becomes 'run_system_info' local func_name="run_${mod//-/_}" + if declare -f "$func_name" > /dev/null; then - shift - "$func_name" "$@" + shift # Remove the module name from the argument list + "$func_name" "$@" # Execute function with remaining args else echo -e "${RED}❌ Error: Function '$func_name' not defined in module '$mod'.${NC}" fi } +# --- Internal Router --- case "$1" in - update) - sudo curl -sSL "$REPO_RAW/core/dynr" -o /usr/local/bin/dynr - sudo chmod +x /usr/local/bin/dynr - echo -e "${GOLD}✨ Dynasty Core updated to v$VERSION.${NC}" - ;; - refresh) - if [ -z "$2" ]; then echo -e "${RED}Usage: dynr refresh ${NC}" - else - rm -f "$MOD_DIR/$2" - load_and_run "$2" - fi - ;; - list) - echo -e "${PURPLE}📜 Locally Manifested Scrolls:${NC}" - ls "$MOD_DIR" 2>/dev/null | sed 's/^/ 🐉 /' || echo " (No modules yet)" - ;; - purge) - echo -e "${RED}🔥 Incinerate the Dynasty Framework? (y/n)${NC}" - read -p "> " confirm - [[ "$confirm" == "y" ]] && sudo rm -rf /opt/dynr /usr/local/bin/dynr && echo "Purged." - ;; - *) - if [ -z "$1" ]; then - echo -e "${PURPLE}🐉 DYNASTY REVOLUTION DYNAMIC CLI v$VERSION${NC}" - echo -e "Usage: ${BLUE}dynr ${NC}" - echo -e "System: ${GOLD}update, refresh, list, purge${NC}" - else - load_and_run "$@" - fi - ;; -esac \ No newline at end of file + # Clean Exit Logic + exit|quit) + FAREWELLS=( + "The \ No newline at end of file