alias b := build
alias c := check
alias f := fmt
alias t := test
alias p := pre-push
alias d := doc

_default:
  @just --list

# Build the project
build:
   cargo build

# Check code: formatting, compilation, linting, and commit signature
check:
   cargo +nightly fmt --all -- --check
   cargo check --workspace --all-features
   cargo clippy --all-features --all-targets -- -D warnings
   @[ "$(git log --pretty='format:%G?' -1 HEAD)" = "N" ] && \
       echo "\n⚠️  Unsigned commit: BDK requires that commits be signed." || \
       true

# Format all code
fmt:
   cargo +nightly fmt

# Run all tests for all crates with all features enabled
test:
   @just _test-bitcoind_rpc
   @just _test-chain
   @just _test-core
   @just _test-electrum
   @just _test-esplora
   @just _test-file_store
   @just _test-testenv

_test-bitcoind_rpc:
    cargo test -p bdk_bitcoind_rpc --all-features

_test-chain:
    cargo test -p bdk_chain --all-features

_test-core:
    cargo test -p bdk_core --all-features

_test-electrum:
    cargo test -p bdk_electrum --all-features

_test-esplora:
    cargo test -p bdk_esplora --all-features

_test-file_store:
    cargo test -p bdk_file_store --all-features

_test-testenv:
    cargo test -p bdk_testenv --all-features

# Run pre-push suite: format, check, and test
pre-push: fmt check test

# Check documentation for all workspace packages
doc:
   RUSTDOCFLAGS='-D warnings' cargo doc --workspace --no-deps
