From 7d4e34b901cba4e90632302959e16ade244edc96 Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Fri, 19 Jun 2026 22:32:41 +0530 Subject: [PATCH] improve routes help --- routes.sh | 101 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 43 deletions(-) diff --git a/routes.sh b/routes.sh index e5a8f79..fe9863a 100755 --- a/routes.sh +++ b/routes.sh @@ -8,10 +8,17 @@ if [ -z "${BASH_VERSION:-}" ]; then exit 1 fi +declare -A INSTALLERS=( + [nvim]="Install Neovim 0.11.7 and configuration" + [yazi]="Install Yazi terminal file manager and dependencies" + [zoxide]="Install Zoxide directory jumper" +) +# Order in which installers should be displayed +INSTALLER_KEYS=(nvim yazi zoxide) + SCRIPT_NAMES="${1:-}" -if [ -z "$SCRIPT_NAMES" ]; then - echo "Usage: b [args...]" >&2 - exit 1 +if [ -z "$SCRIPT_NAMES" ] || [ "$SCRIPT_NAMES" = "-h" ] || [ "$SCRIPT_NAMES" = "--help" ]; then + SCRIPT_NAMES="all" fi shift @@ -19,46 +26,54 @@ shift IFS=',' read -ra SCRIPTS <<< "$SCRIPT_NAMES" for script in "${SCRIPTS[@]}"; do - case "$script" in - nvim) - echo "Launching Neovim installer..." - curl -fsSL "https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/installers/install_nvim.sh" | bash -s -- "$@" - ;; - yazi) - echo "Launching Yazi installer..." - curl -fsSL "https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/installers/install_yazi.sh" | bash -s -- "$@" - ;; - zoxide) - echo "Launching Zoxide installer..." - curl -fsSL "https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/installers/install_zoxide.sh" | bash -s -- "$@" - ;; - bye) - echo "Removing bootstrap CLI completely..." - - target_files=() - [ -f "$HOME/.bashrc" ] && target_files+=("$HOME/.bashrc") - [ -f "$HOME/.zshrc" ] && target_files+=("$HOME/.zshrc") + # Check if it is a registered installer + if [[ -n "${INSTALLERS[$script]:-}" ]]; then + # Capitalize first letter for display (e.g. nvim -> Neovim) + display_name="$(echo "${script:0:1}" | tr '[:lower:]' '[:upper:]')${script:1}" + echo "Launching ${display_name} installer..." + curl -fsSL "https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/installers/install_${script}.sh" | bash -s -- "$@" - for config_file in "${target_files[@]}"; do - # Remove loader setup - if grep -q "# >>> bootstrap-cli setup >>>" "$config_file" 2>/dev/null; then - sed -i '/# >>> bootstrap-cli setup >>>/,/# <<< bootstrap-cli setup <<>> bootstrap-cli b function >>>" "$config_file" 2>/dev/null; then - sed -i '/# >>> bootstrap-cli b function >>>/,/# <<< bootstrap-cli b function <<&2 - echo "Available scripts: nvim, yazi, zoxide, bye" >&2 - exit 1 - ;; - esac + for config_file in "${target_files[@]}"; do + # Remove loader setup + if grep -q "# >>> bootstrap-cli setup >>>" "$config_file" 2>/dev/null; then + sed -i '/# >>> bootstrap-cli setup >>>/,/# <<< bootstrap-cli setup <<>> bootstrap-cli b function >>>" "$config_file" 2>/dev/null; then + sed -i '/# >>> bootstrap-cli b function >>>/,/# <<< bootstrap-cli b function <<&2 + echo "Run 'b all' to list all available commands." >&2 + exit 1 + ;; + esac + fi done