#!/bin/bash

# Build SDK
build:
    cargo build

# Build SDK in release mode
build-release:
    cargo build --release

# Clean the build directory
clean:
    cargo clean
    rm -rf build

# Run clippy code checks
clippy:
    cargo clippy --tests --no-deps --all-features -- -Dclippy::all -Dclippy::pedantic

# Run all tests
all-tests: test doctest

# Run tests using cargo nextest if installed
test:
    bash -c 'if which cargo-nextest > /dev/null 2>&1; then cargo nextest run; else cargo test --tests; fi'

# Run documentation tests
doctest:
    cargo test --doc --target x86_64-unknown-linux-gnu

# Run code coverage
cov:
    cargo llvm-cov

# Check coverage
cov-check:
    tools/check_coverage.sh

# Generate code coverage HTML
cov-html:
    cargo llvm-cov --html

# Open code coverage HTML
cov-open:
    python3 -m http.server -d target/llvm-cov/html 8000

# Generate documentation
doc:
    cargo doc --no-deps --all-features --document-private-items

# Open documentation
doc-open:
    python3 -m http.server -d target/x86_64-unknown-linux-musl/doc 8001

# Run cargo deny to check licenses
deny:
    cargo deny check

# Find the minimum supported Rust version (MSRV)
msrv-find:
    bash -c 'if ! which cargo-msrv > /dev/null 2>&1; then cargo install cargo-msrv; fi'
    cargo msrv find --include-all-patch-releases --linear # --output-format minimal
