# hamel package justfile

# Show available commands
default:
    @just --list

# Install package in development mode
install:
    uv pip install -e .

# Install with dev dependencies (pytest, ruff, build, twine)
install-dev:
    uv pip install -e ".[dev]"

# Run the test suite (skips tests that hit the live Gemini API)
test:
    uv run pytest -v -m 'not slow'

# Run every test, including the ones that call the live Gemini API
test-all:
    uv run pytest -v

# Lint
lint:
    uv run ruff check hamel tests

# Auto-fix what ruff can. Deliberately NOT `ruff format`: it would rewrite the
# `if x: return y` one-liner house style that the E701 ignore protects.
fmt:
    uv run ruff check --fix hamel tests

# Everything CI runs, locally (lint + tests + distribution build check)
check: lint test build-check

# Show current version
version:
    @uv run python -c "import hamel; print(hamel.__version__)"

# Bump the patch version in hamel/__init__.py
bump:
    @uv run python -c "import pathlib, re; p = pathlib.Path('hamel/__init__.py'); t = p.read_text(); m = re.search(r'__version__ = \"(\d+)\.(\d+)\.(\d+)\"', t); n = f'{m[1]}.{m[2]}.{int(m[3]) + 1}'; p.write_text(t[:m.start()] + f'__version__ = \"{n}\"' + t[m.end():]); print('bumped to', n)"

# Build the wheel and sdist into dist/
build:
    rm -rf build/ dist/ *.egg-info
    uv run python -m build

# Verify the built distribution is well formed
build-check: build
    uv run twine check dist/*

# Publish to PyPI
publish: build-check
    uv run twine upload dist/*

# Full release: lint+test, bump, then build+publish. Deliberately NOT
# `release: check ...`: just dedups shared dependencies, so check's build-check
# would satisfy publish's and the pre-bump dist would be uploaded.
release: lint test bump publish
    @echo "Released. Don't forget to commit and push the version bump."
