| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #!/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" "$@"
|