.PHONY: help install test lint format clean build run

help:
	@echo "Available commands:"
	@echo "  install       Install dependencies"
	@echo "  test          Run tests"
	@echo "  test <file>   Run specific test file"
	@echo "  lint          Run linting"
	@echo "  format        Format code"
	@echo "  clean         Clean build artifacts"
	@echo "  build         Build package"
	@echo "  run           Start the mckicad MCP server"

install:
	uv sync --group dev

test:
	@files="$(filter-out $@,$(MAKECMDGOALS))"; \
	if [ -z "$$files" ]; then files="tests/"; fi; \
	uv run pytest $$files -v

# Prevent "No rule to make target …" errors for extra args
%::
	@:

lint:
	uv run ruff check src/mckicad/ tests/
	uv run mypy src/mckicad/

format:
	uv run ruff format src/mckicad/ tests/
	uv run ruff check --fix src/mckicad/ tests/

clean:
	rm -rf dist/ build/ *.egg-info/ .pytest_cache/ htmlcov/
	rm -f coverage.xml
	find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
	find . -type f -name "*.pyc" -delete 2>/dev/null || true

build:
	uv build

run:
	uv run python main.py
