# --- Environment Configuration ---
# Set RUSTFLAGS globally for clippy tasks to enforce rules.

RUSTFLAGS := "-Dclippy::all"

# --- Build Tasks ---
build:
    cargo build --workspace --all-features

# Build for all targets
build-all:
    cargo build --workspace --all-features --all-targets

# Build in release mode
build-release:
    cargo build --workspace --all-features --release

# --- Formatting Tasks ---

# Format Rust code
fmt:
    cargo fmt --all

# Format TOML files (requires taplo: `cargo install taplo-cli`)
fmt-toml:
    taplo fmt

# Check Rust code formatting
fmt-check:
    cargo fmt --check --all

# Run all formatters
fmt-all: fmt fmt-toml

# --- Check & Lint Tasks ---

# Check the workspace for errors
check:
    cargo check --workspace --all-features

# Check the workspace for errors across all targets
check-all:
    cargo check --workspace --all-features --all-targets

# Check for typos (requires typos-cli: `cargo install typos-cli`)
typos:
    typos -w

# Run clippy linter
lint:
    cargo clippy --workspace --all-features

# Run clippy linter for all targets
lint-all:
    cargo clippy --workspace --all-features --all-targets

# --- Fix Tasks ---

# Apply automated fixes (rustfmt, suggestions)
fix:
    cargo fix --workspace --all-features --all-targets --allow-staged

# Apply clippy fixes
lint-fix:
    cargo clippy --workspace --all-features --all-targets --fix --allow-staged

# --- Test Tasks ---

# Run tests (requires cargo-nextest: `cargo install cargo-nextest`)
test:
    cargo nextest run --workspace --all-features --all-targets

# --- Run Tasks ---

# Run the main project binary
run:
    cargo run --bin llm-brain

# Run the main project binary in release mode
run-release:
    cargo run --bin llm-brain --release

# Check for outdated dependencies (requires cargo-outdated: `cargo install cargo-outdated`)
outdated:
    cargo outdated --workspace

# --- Publishing ---

# Publish workspace to crates.io (requires cargo-release: `cargo install cargo-release`)
publish:
    cargo release publish --workspace --execute --no-confirm --registry crates-io

# --- Meta Tasks (Hooks) ---

# Tasks to run before committing
precommit: typos fmt-all fix lint-fix

# Tasks to run before deploying
predeploy: fmt-check check-all lint-all test

# Basic checks
precheck: fmt-check check-all
