# Pass recipe arguments through as real positional args ($@) instead of a
# space-joined string, so forwarded values keep their quoting (e.g.
# `just test -E 'test(some_name)'` reaches nextest as two intact args).
set positional-arguments := true

fmt_toolchain := "nightly-2025-09-27"
udeps_toolchain := "nightly-2026-07-29"

fmt:
  rustup toolchain install {{fmt_toolchain}} && \
  cargo +{{fmt_toolchain}} fmt && \
  cargo sort --workspace --grouped

fmt-check:
  rustup toolchain install {{fmt_toolchain}} && \
  cargo +{{fmt_toolchain}} fmt --check

check-features:
  cargo check -p protocol --no-default-features --locked && \
  cargo check -p protocol --locked

# Two passes: doc lints apply to library code only, while the second pass lints
# every target (unit/integration tests, test-harness included) so dead test
# helpers and unused test deps can't accumulate unseen.
clippy:
  cargo clippy --workspace --all-features --no-deps --exclude bindings --exclude test-harness -- -D warnings -D missing_docs -D clippy::missing_docs_in_private_items && \
  cargo clippy --workspace --all-targets --all-features --no-deps --exclude bindings -- -D warnings

clippy-fix:
  cargo clippy --fix --workspace --all-features --no-deps --exclude bindings --allow-dirty --allow-staged -- -D warnings

udeps:
  rustup toolchain install {{udeps_toolchain}} --profile minimal && \
  cargo +{{udeps_toolchain}} udeps --all-targets

test *ARGS:
  ./tests/entrypoint.sh "$@"

# Unit tests only (everything outside `tests/` dirs): no docker env, no contract
# deploy — sub-minute feedback. The protocol pass also compiles and runs its tests
# without default features so test-only feature leaks stay covered in CI.
# Extra args are forwarded to nextest.
unit *ARGS:
  cargo nextest run --workspace --exclude bindings --all-features -E '!kind(test)' "$@" && \
  cargo nextest run -p protocol --no-default-features "$@"

gen_bindings:
  ./script/gen_bindings.sh
