# ─── Build ──────────────────────────────────────────────

.PHONY: install
install: ## Install clu into the active venv
	uv sync
	uv pip install -e .

.PHONY: run
run: ## Run without installing (pass ARGS, e.g. make run ARGS="status")
	uv run clu $(ARGS)

# ─── Dev ────────────────────────────────────────────────

.PHONY: sync
sync: ## Sync dependencies
	uv sync

.PHONY: fmt
fmt: ## Format all Python files
	uv run ruff format src/
	@echo "formatted"

.PHONY: lint
lint: ## Run ruff linter
	uv run ruff check src/

.PHONY: lint-fix
lint-fix: ## Run ruff linter with auto-fix
	uv run ruff check --fix src/

.PHONY: typecheck
typecheck: ## Run ty type checker
	uv run ty check src/

# ─── Test ───────────────────────────────────────────────

.PHONY: test
test: ## Run all tests
	uv run python -m pytest tests/ -q

.PHONY: test-v
test-v: ## Run tests with verbose output
	uv run python -m pytest tests/ -v

# ─── Check ──────────────────────────────────────────────

.PHONY: check
check: fmt lint typecheck ## Format, lint, and typecheck (pre-commit sanity check)

.PHONY: ci
ci: lint typecheck test ## Full CI pipeline locally

# ─── Clean ──────────────────────────────────────────────

.PHONY: clean
clean: ## Remove build artifacts
	rm -rf dist/ build/ *.egg-info src/*.egg-info .ruff_cache .pytest_cache

# ─── Help ───────────────────────────────────────────────

.PHONY: help
help: ## Show this help
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
		awk 'BEGIN {FS = ":.*?## "}; {printf "  \033[36m%-14s\033[0m %s\n", $$1, $$2}'

.DEFAULT_GOAL := help
