# dnd-daemon Makefile

SHELL := bash
.DEFAULT_GOAL := help

.PHONY: help
help: ## show this help message
	@echo "dnd-daemon Development Tools"
	@echo ""
	@echo "Usage: make <target>"
	@echo ""
	@echo "Targets:"
	@awk 'BEGIN {FS = ":.*##"; printf "\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf "  \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Setup

.PHONY: install install-dev
install: ## install the package
	pip install .

install-dev: ## install in development mode
	pip install -e ".[dev]"

##@ Linting

.PHONY: lint lint/black lint/isort lint/autoflake lint/pyright lint/codespell format format/black format/isort format/autoflake
lint: lint/black lint/isort lint/autoflake lint/pyright lint/codespell ## run all linters

lint/black: ## check style with black
	black --check src/dnd

lint/isort: ## check import order
	isort --check-only src/dnd

lint/autoflake: ## check for unused imports
	autoflake --recursive --remove-all-unused-imports --check src/dnd

lint/pyright: ## run type checking
	pyright

lint/codespell: ## check for misspellings
	codespell src/dnd

format: format/autoflake format/isort format/black ## format all code

format/black: ## format code with black
	black src/dnd

format/isort: ## format imports with isort
	isort src/dnd

format/autoflake: ## remove unused imports
	autoflake --recursive --remove-all-unused-imports --in-place src/dnd

##@ Testing

.PHONY: test test/unit test/coverage
test: test/unit ## run all tests

test/unit: ## run unit tests
	pytest tests/ -v --tb=short

test/coverage: ## run tests with coverage
	pytest --cov=dnd --cov-report=term-missing

##@ Building

.PHONY: build clean
build: clean ## build the package
	python -m build

clean: ## clean build artifacts
	rm -rf build/ dist/ *.egg-info/ src/*.egg-info/ .pytest_cache/
	find . -type d -name __pycache__ -exec rm -rf {} +
	find . -type f -name "*.pyc" -delete

##@ Release

.PHONY: version
version: ## show current version
	python -c "import dnd; print(dnd.__version__)"
