.DEFAULT_GOAL := help
.PHONY: help install uninstall cleanup test check

help: ## List available targets
	@awk 'BEGIN {FS = ":.*## "} /^[a-zA-Z0-9_-]+:.*## / {printf "  %-12s %s\n", $$1, $$2}' $(MAKEFILE_LIST)

install: ## Install or refresh tamq as a user-level uv tool
	@command -v uv >/dev/null || { echo "tamq: uv is required; install it from https://docs.astral.sh/uv/" >&2; exit 1; }
	uv tool install --force --reinstall --refresh .
	@command -v tamq >/dev/null || { echo "tamq: installed, but the uv tool bin directory is not on PATH; run 'uv tool update-shell'" >&2; exit 1; }
	tamq --version

uninstall: ## Uninstall the user-level tamq tool
	uv tool uninstall tmux-amq

cleanup: ## Stop tamq and remove tamq-owned runtime files (preserves history)
	uv run tamq cleanup --yes

test: ## Run the test suite
	uv run pytest

check: ## Run tests and repository consistency checks
	uv run pytest
	git diff --check
	python3 -m compileall -q src
