gitcore 1.4.0

A secure, zero-friction Git identity manager for developers who juggle multiple accounts.
Documentation
#!/bin/sh
# gitcore - Git Account Manager Installation Script
# Supports: Linux, macOS, Android (Termux)

set -e

show_help() {
    printf "gitcore installer - Manage multiple Git accounts safely\n\n"
    printf "Usage:\n"
    printf "  curl -fsSL https://shedrackgodstime.github.io/gitcore/install | sh [OPTIONS]\n\n"
    printf "Options:\n"
    printf "  help      Show this help message\n\n"
    printf "Examples:\n"
    printf "  # Install gitcore\n"
    printf "  curl -fsSL https://shedrackgodstime.github.io/gitcore/install | sh\n"
    exit 0
}

for arg in "$@"; do
    case "$arg" in
        help|--help|-h) show_help ;;
    esac
done

printf "\n\033[1;36m[*] Installing gitcore - Git Account Manager...\033[0m\n"
printf "\033[0;34m--------------------------------------------------\033[0m\n"

OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"

case "$OS" in
  linux)
    case "$ARCH" in
      x86_64) TARGET="x86_64-unknown-linux-gnu" ;;
      aarch64|arm64) TARGET="aarch64-unknown-linux-musl" ;;
      *) printf "\n\033[0;31m[-] Error: Unsupported Linux Architecture: $ARCH\033[0m\n"; exit 1 ;;
    esac
    ;;
  darwin)
    case "$ARCH" in
      x86_64) TARGET="x86_64-apple-darwin" ;;
      aarch64|arm64) TARGET="aarch64-apple-darwin" ;;
      *) printf "\n\033[0;31m[-] Error: Unsupported macOS Architecture: $ARCH\033[0m\n"; exit 1 ;;
    esac
    ;;
  *)
    printf "\033[0;31m[-] Error: Unsupported OS: $OS\033[0m\n"
    exit 1
    ;;
esac

ASSET_NAME="gitcore-${TARGET}.tar.gz"
RELEASE_URL="https://api.github.com/repos/shedrackgodstime/gitcore/releases/latest"

printf "[*] Fetching latest release...\n"
DOWNLOAD_URL=$(curl -s "$RELEASE_URL" | grep "browser_download_url" | grep "gitcore-${TARGET}" | head -n 1 | cut -d '"' -f 4)

if [ -z "$DOWNLOAD_URL" ]; then
  printf "\033[0;31m[-] Error: Could not find asset $ASSET_NAME\033[0m\n"
  printf "    Check your repository and releases: $RELEASE_URL\n"
  exit 1
fi

TMP_DIR=$(mktemp -d)
printf "[+] Downloading $ASSET_NAME...\n"
curl -sL "$DOWNLOAD_URL" -o "$TMP_DIR/gitcore.tar.gz"

printf "[*] Unpacking...\n"
tar -xzf "$TMP_DIR/gitcore.tar.gz" -C "$TMP_DIR"

DEST_DIR="/usr/local/bin"
if [ ! -w "$DEST_DIR" ]; then
    DEST_DIR="$HOME/.local/bin"
    mkdir -p "$DEST_DIR"
fi

cp "$TMP_DIR/gitcore" "$DEST_DIR/"
chmod +x "$DEST_DIR/gitcore"
printf "[+] Installed gitcore to $DEST_DIR\n"

rm -rf "$TMP_DIR"

printf "\033[1;32m[+] Success! gitcore installed\033[0m\n"
printf "\033[0;34m--------------------------------------------------\033[0m\n"

if echo "$PATH" | grep -q "$DEST_DIR"; then
    printf " * Add account:   \033[1mgitcore add\033[0m\n"
    printf " * List accounts: \033[1mgitcore list\033[0m\n"
    printf " * Clone repo:    \033[1mgitcore clone\033[0m\n"
    printf " * Security:      \033[1mgitcore audit\033[0m\n"
    printf " * Help:          \033[1mgitcore --help\033[0m\n"
else
    printf "\033[0;33m[!] Warning: $DEST_DIR not in PATH\033[0m\n"
    
    SHELL_NAME=$(basename "$SHELL")
    case "$SHELL_NAME" in
        zsh)  RC_FILE="$HOME/.zshrc" ;;
        bash) RC_FILE="$HOME/.bashrc" ;;
        *)    RC_FILE="$HOME/.profile" ;;
    esac

    printf "To fix, run:\n"
    printf "  echo 'export PATH=\"\$PATH:$DEST_DIR\"' >> $RC_FILE\n"
    printf "Then restart your terminal or run: source $RC_FILE\n"
fi

printf "\n * Uninstall: \033[1mcurl -fsSL https://shedrackgodstime.github.io/gitcore/uninstall | sh\033[0m\n"
printf "\n"