.PHONY: test lint format ci clean

test:
	pytest scanner/tests/ \
		--ignore=scanner/tests/test_card_push.py \
		--ignore=scanner/tests/test_cards.py \
		--ignore=scanner/tests/test_drive_modes.py \
		--ignore=scanner/tests/test_public_api.py \
		-q

lint:
	@if command -v ruff >/dev/null 2>&1; then \
		ruff check .; \
	elif command -v flake8 >/dev/null 2>&1; then \
		flake8 .; \
	else \
		echo "No linter found. Install ruff or flake8."; exit 1; \
	fi

format:
	@if command -v ruff >/dev/null 2>&1; then \
		ruff format .; \
	elif command -v black >/dev/null 2>&1; then \
		black .; \
	else \
		echo "No formatter found. Install ruff or black."; exit 1; \
	fi

ci: lint test

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