set shell := ["bash", "-uc"]

# List the available commands
help:
    @just --list --justfile {{justfile()}}

# Prepare the environment for development, installing all the dependencies and
# setting up the pre-commit hooks.
setup:
    uv sync
    [[ -n "${JUST_INHIBIT_GIT_HOOKS:-}" ]] || uv run pre-commit install -t pre-commit

# Prepare the environment for development, including the extra dependency groups.
setup-extras:
    uv sync --extra pytket --inexact

# Run the pre-commit checks.
check:
    uv run pre-commit run --all-files


# Run the tests.
test *PYTEST_FLAGS:
    uv run pytest -n auto {{PYTEST_FLAGS}}

# Export the integration test cases to a directory.
export-integration-tests directory="guppy-exports":
    uv run pytest --export-test-cases="{{ directory }}"

# Auto-fix all clippy warnings.
fix:
    uv run ruff check --fix guppylang

# Format the code.
format:
    uv run ruff format guppylang

# Generate a test coverage report.
coverage:
    uv run pytest --cov=./ --cov-report=html

# Generate the documentation.
build-docs:
    cd docs && ./build.sh

# Serve sphinx docs locally (needs npm installed)
serve-docs: build-docs
    npm exec serve docs/build/api-docs

# Remove files generated by the sphinx build
clean-docs:
    rm -rf docs/build
    rm -rf docs/api-docs/generated

# Package the code and store the wheels in the dist/ directory.
build-wheels:
    uvx --from build pyproject-build --installer uv

# Run benchmarks using pytest-benchmark.
bench *PYTEST_FLAGS:
    uv run pytest --benchmark-only {{PYTEST_FLAGS}}

# Run benchmarks and save JSON data to path/name.json.
bench_save path name:
    uv run pytest --benchmark-only --benchmark-storage={{path}} --benchmark-save={{name}}
