.PHONY: test lint fmt build run-local clean all copy run

# Default target
default: test

# Build the binary
build:
	go build -o rtnetmon ./cmd/rtnetmon

# Run tests
test: lint
	go test -v ./...

# Run linter
lint:
	golangci-lint run --config .golangci.yml ./...

# Format code
fmt:
	go fmt ./...

# Run the application locally
run-local: build
	./rtnetmon

# Clean build artifacts
clean:
	rm -f rtnetmon
	rm -f main.go.old

# Build and test everything
all: fmt lint test build

# Remote deployment targets
copy:
	ssh root@las1stor1 -v "mkdir -p /tmp/x"
	rsync -av --exclude='.git' --exclude='*.test' --exclude='/rtnetmon' --exclude='main.go.old' ./ root@las1stor1:/tmp/x/

run: copy
	ssh -t root@las1stor1 -v "cd /tmp/x && go run ./cmd/rtnetmon"
