#!/usr/bin/env bash
# cli.johlem.net global uninstaller
#
# Usage:
#   curl -fsSL https://cli.johlem.net/uninstall.sh | bash -s -- urlrecon
#   curl -fsSL https://cli.johlem.net/uninstall.sh | bash -s -- --tool urlrecon
set -euo pipefail

TOOL=""

# Parse arguments
while [ $# -gt 0 ]; do
  case "$1" in
    --tool)
      TOOL="$2"
      shift 2
      ;;
    --tool=*)
      TOOL="${1#*=}"
      shift
      ;;
    -*)
      echo "[ERROR] Unknown flag: $1"
      exit 1
      ;;
    *)
      TOOL="$1"
      shift
      ;;
  esac
done

if [ -z "$TOOL" ]; then
  echo "==================================="
  echo " cli.johlem.net — Tool Uninstaller"
  echo "==================================="
  echo ""
  echo "Usage:"
  echo "  curl -fsSL https://cli.johlem.net/uninstall.sh | bash -s -- <tool>"
  echo ""
  echo "Available tools:"
  echo "  urlrecon    Async multi-module URL reconnaissance tool"
  echo ""
  echo "Example:"
  echo "  curl -fsSL https://cli.johlem.net/uninstall.sh | bash -s -- urlrecon"
  exit 1
fi

echo "[cli.johlem.net] Uninstalling ${TOOL}..."
curl -fsSL "https://cli.johlem.net/tools/${TOOL}/uninstall.sh" | bash
