# Makefile for standard Python Flask application

# Variables
PYTHON := python3
PIP := pip3
FLASK_APP := src/app.py
TESTS := tests/

# Default target
.PHONY: help
help:
	@echo "Available targets:"
	@echo "  setup     - Set up development environment"
	@echo "  install   - Install dependencies"
	@echo "  run       - Run development server"
	@echo "  test      - Run tests"
	@echo "  lint      - Run code linting"
	@echo "  format    - Format code with Black"
	@echo "  clean     - Clean up temporary files"

# Set up development environment
.PHONY: setup
setup:
	$(PYTHON) -m venv venv
	. venv/bin/activate && $(PIP) install -r requirements/development.txt

# Install dependencies
.PHONY: install
install:
	$(PIP) install -r requirements/development.txt

# Run development server
.PHONY: run
run:
	FLASK_APP=$(FLASK_APP) flask run --host=0.0.0.0 --port=5000 --debug

# Run tests
.PHONY: test
test:
	$(PYTHON) -m pytest $(TESTS) -v

# Run code linting
.PHONY: lint
lint:
	flake8 src/ tests/

# Format code with Black
.PHONY: format
format:
	black src/ tests/

# Clean up temporary files
.PHONY: clean
clean:
	find . -type f -name "*.pyc" -delete
	find . -type d -name "__pycache__" -delete
	rm -rf .pytest_cache/
	rm -rf .coverage
	rm -rf htmlcov/
	rm -rf *.egg-info/
	rm -rf dist/
	rm -rf build/