# List all commands.
default:
  @just --list

# Build docs.
docs:
  rm -rf docs/build docs/source/_autosummary
  uv run make -C docs html
  echo Docs are in $PWD/docs/build/html/index.html

# Do a dev install.
dev:
  uv sync --all-extras --dev

# Run code checks.
check:
  #!/usr/bin/env bash

  error=0
  trap error=1 ERR

  echo
  (set -x; uv run ruff check src/ tests/ docs/source/ examples/ dev/ )
  test $? = 0

  echo
  ( set -x; uv run ruff format --check src/ tests/ docs/source/ examples/ dev/ )
  test $? = 0

  echo
  ( set -x; uv run mypy src/ tests/ docs/source/ examples/ dev/ )
  test $? = 0

  echo
  ( set -x; uv run pytest )
  test $? = 0

  echo
  ( set -x; uv run make -C docs doctest )
  test $? = 0

  test $error = 0

# Auto-fix code issues.
fix:
  uv run ruff format src/ tests/ docs/source/ examples/ dev/
  uv run ruff check --fix src/ tests/ docs/source/ examples/ dev/

# Build a release.
build:
  uv build

# Populate a MongoDB database with test data
init_nomad_nmr_test_db nomad-datastore mongo-uri="mongodb://localhost:27017":
  uv run dev/init_nomad_nmr_test_db.py \
    {{mongo-uri}} {{nomad-datastore}} dev/nmr-data
