feat: Added easy reinstallation

This commit is contained in:
2026-06-21 12:36:53 +05:30
parent 004946f4b2
commit 3df936d501
8 changed files with 64 additions and 21 deletions

View File

@@ -7,6 +7,6 @@ printf " %-6s - %s\n" "all" "List all available commands"
printf " %-6s - %s\n" "con" "Edit config (e.g. b con nvim)"
printf " %-6s - %s\n" "up" "Check for updates and update Bootstrap CLI"
printf " %-6s - %s\n" "ware" "Edit and run an installer (e.g. b ware nvim)"
printf " %-6s - %s\n" "bye" "Uninstall Bootstrap CLI helper"
printf " %-6s - %s\n" "gone" "Uninstall Bootstrap CLI helper"

View File

@@ -1,4 +1,4 @@
# Command: uninstall (bye)
# Command: uninstall (gone)
# Removes bootstrap CLI and cleans up shell configuration files
# Source libraries if needed (should already be sourced by routes.sh, but just in case)
@@ -7,7 +7,20 @@ if [ -z "${_LIB_SHELL_CONFIG_SOURCED:-}" ]; then
. "$_LIB_DIR/shell_config.sh"
fi
log_info "Removing bootstrap CLI completely..."
# Check if force flag is passed (-f or --force)
FORCE=false
for arg in "$@"; do
if [ "$arg" = "-f" ] || [ "$arg" = "--force" ]; then
FORCE=true
break
fi
done
if [ "$FORCE" = "true" ]; then
log_info "Removing bootstrap CLI completely..."
else
log_info "Uninstalling bootstrap CLI (leaving 'b back' shortcut)..."
fi
# Get targets using the library function
IFS=' ' read -ra target_files <<< "$(get_shell_configs)"
@@ -46,7 +59,31 @@ if [ -f "$HOME/.bash_aliases" ]; then
fi
fi
# If force is false, leave a lightweight 'b back' shortcut function in shell config files
if [ "$FORCE" = "false" ]; then
local b_back_content
b_back_content=$(cat << 'EOF'
b() {
if [ "${1:-}" = "back" ]; then
curl -fsSL https://adityagupta.dev/b | bash
else
echo "Bootstrap is uninstalled. Run 'b back' to reinstall it."
fi
}
EOF
)
for config_file in "${target_files[@]}"; do
inject_block "$config_file" "bootstrap-cli setup" "$b_back_content"
done
fi
# Remove the installation directory
rm -rf "${BOOTSTRAP_DIR:-$HOME/.config/bootstrap}"
log_success "Bootstrap CLI removed successfully. (Note: Run 'unset -f b' to clear it from the current session)"
if [ "$FORCE" = "true" ]; then
log_success "Bootstrap CLI completely removed. (Note: Run 'unset -f b' to clear the function from the current session)"
else
log_success "Bootstrap CLI uninstalled."
log_info "A lightweight 'b back' shortcut has been left in your shell config to allow easy re-installation."
log_info "To remove Bootstrap CLI completely and leave no shortcuts, run: b gone -f"
fi