set windows-shell := ["C:/Program Files/Git/bin/bash.exe", "-c"]

# Auto-load `.env` (gitignored) for per-developer overrides such as
# DISPLAY / XAUTHORITY consumed by `just e2e-test` on Linux SSH sessions.
# `.env.example` documents the defaults; existing shell environment
# variables take precedence over `.env` (dotenv-override = false).
set dotenv-load := true

# Default recipe (shows help)
default:
    @just --list

# Show help
help:
    @just --list

# Clean autogenerated files
clean:
    rm -rf dist
    find . -type f -name "*.DS_Store" -ls -delete
    find . | grep -E "(__pycache__|\.pyc|\.pyo)" | xargs rm -rf
    find . | grep -E ".pytest_cache" | xargs rm -rf
    find . | grep -E ".ipynb_checkpoints" | xargs rm -rf
    rm -f .coverage

# Setup the environment
setup:
    uv venv --clear
    uv sync --all-extras
    uv run pre-commit install

# Run pre-commit hooks
format:
    uv run pre-commit run -a

# Run pytest
test:
    uv run pytest -v --cov

# Run pyright
type:
    uv run pyright

# Run all workflow (format, test, type)
run: format test type

# Run an end-to-end scenario script (default: all scenarios; e.g. `just e2e-test launch_terminate`)
# On Linux SSH sessions, falls back to the active local X11 display so GUI apps render on the desktop.
e2e-test NAME="all":
    DISPLAY="${DISPLAY:-:0}" XAUTHORITY="${XAUTHORITY:-$HOME/.Xauthority}" uv run python tests/e2e/{{NAME}}.py
