#!/bin/bash set -e # Colors RED="\033[0;31m" GREEN="\033[0;32m" YELLOW="\033[1;33m" NC="\033[0m" echo -e "${GREEN}" echo " _ _ _______ __" echo " | \ | | ____\ \/ /" echo " | \| | _| \ / " echo " | |\ | |___ / \ " echo " |_| \_|_____/_/\_\\" echo -e "${NC}" echo "NEX CLI Installer" echo "==================" echo # Detect OS and architecture OS=$(uname -s | tr "[:upper:]" "[:lower:]") ARCH=$(uname -m) case "$ARCH" in x86_64|amd64) ARCH="x86_64" ;; aarch64|arm64) ARCH="arm64" ;; *) echo -e "${RED}Error: Unsupported architecture: $ARCH${NC}" exit 1 ;; esac case "$OS" in linux) PLATFORM="linux" ;; darwin) PLATFORM="macos" ;; *) echo -e "${RED}Error: Unsupported OS: $OS${NC}" exit 1 ;; esac BINARY="nex-${PLATFORM}-${ARCH}" URL="https://nex.lily.ong/releases/latest/${BINARY}" echo -e "Platform: ${YELLOW}${PLATFORM}-${ARCH}${NC}" echo -e "Downloading from: ${YELLOW}${URL}${NC}" echo # Download TMP_DIR=$(mktemp -d) cd "$TMP_DIR" if command -v curl &> /dev/null; then curl -fsSL "$URL" -o nex elif command -v wget &> /dev/null; then wget -q "$URL" -O nex else echo -e "${RED}Error: curl or wget required${NC}" exit 1 fi chmod +x nex # Install INSTALL_DIR="/usr/local/bin" if [ -w "$INSTALL_DIR" ]; then mv nex "$INSTALL_DIR/nex" else echo -e "${YELLOW}Installing to $INSTALL_DIR (requires sudo)${NC}" sudo mv nex "$INSTALL_DIR/nex" fi # Cleanup cd - > /dev/null rm -rf "$TMP_DIR" # Verify if command -v nex &> /dev/null; then echo echo -e "${GREEN}✓ NEX CLI installed successfully!${NC}" echo nex --version 2>/dev/null || echo "nex installed" echo echo "Get started:" echo " nex init --lang=c # Create C project" echo " nex init --lang=py # Create Python project" echo " nex run # Build and run" else echo -e "${RED}Error: Installation failed${NC}" exit 1 fi