dev/dev

47 lines
1,015 B
Bash
Executable file

#!/usr/bin/env bash
# Simple dev tool launcher - builds if needed
set -euo pipefail
# Change to script's directory
cd "$(dirname "${BASH_SOURCE[0]}")"
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
log() { echo -e "${GREEN}[DEV]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
# Simple platform detection
ARCH=$(uname -m)
case $ARCH in
x86_64) ARCH="amd64" ;;
arm64 | aarch64) ARCH="arm64" ;;
*)
error "Unsupported arch: $ARCH"
exit 1
;;
esac
BINARY="bin/dev-linux-$ARCH"
# Build if binary doesn't exist or source is newer
if [[ ! -f "$BINARY" ]] || [[ "main.go" -nt "$BINARY" ]]; then
if ! command -v go &>/dev/null; then
error "Go not installed. Install with: sudo pacman -S go"
exit 1
fi
log "Building dev tool..."
mkdir -p bin
go mod tidy
if go build -ldflags="-s -w" -o "$BINARY" main.go; then
log "✅ Built: $BINARY"
else
error "Build failed"
exit 1
fi
fi
# Run the binary
exec "$BINARY" "$@"