.PHONY: lint check test ci bump-major bump-minor bump-patch

lint:
	uv run ruff check --fix
	uv run ruff format
	uv run mypy .

check:
	uv run ruff check
	uv run ruff format --check
	uv run mypy .

test:
	uv run pytest

ci: check test

bump-major bump-minor bump-patch:
	@current=$$(grep '^version' pyproject.toml | sed 's/.*"\(.*\)"/\1/'); \
	major=$$(echo $$current | cut -d. -f1); \
	minor=$$(echo $$current | cut -d. -f2); \
	patch=$$(echo $$current | cut -d. -f3); \
	if [ "$@" = "bump-major" ]; then new="$$((major + 1)).0.0"; \
	elif [ "$@" = "bump-minor" ]; then new="$$major.$$((minor + 1)).0"; \
	else new="$$major.$$minor.$$((patch + 1))"; fi; \
	sed -i '' "s/^version = \"$$current\"/version = \"$$new\"/" pyproject.toml; \
	echo "Bumped $$current -> $$new"
	uv lock
