APP_NAME := bouncer
VENV := .venv
PIP := $(VENV)/bin/pip
PYTHON := $(VENV)/bin/python
BOUNCER := $(VENV)/bin/bouncer

.PHONY: help venv install dev lint fmt test run clean build up down logs

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

venv: ## Create virtual environment
	python3 -m venv $(VENV)
	$(PIP) install --upgrade pip

install: venv ## Install package (editable)
	$(PIP) install -e .

dev: venv ## Install with dev dependencies
	$(PIP) install -e ".[dev]"

lint: ## Run linter
	$(VENV)/bin/ruff check src/ tests/

fmt: ## Format code
	$(VENV)/bin/black src/ tests/
	$(VENV)/bin/ruff check --fix src/ tests/

test: ## Run tests
	$(VENV)/bin/pytest -v

run: ## Run bouncer locally
	$(BOUNCER) --config config/bouncer.toml

build: ## Build container image
	podman-compose build

up: ## Start container (podman-compose)
	podman-compose up -d

down: ## Stop container
	podman-compose down

logs: ## Tail container logs
	podman logs -f $(APP_NAME)

clean: ## Remove build artifacts
	rm -rf $(VENV) dist build *.egg-info src/*.egg-info
