version: "3"

tasks:
  lint:
    desc: Run linter
    cmds:
      - cargo clippy --all-targets --all-features -- -D warnings

  format:
    desc: Check code formatting
    cmds:
      - cargo fmt --

  build-release:
    desc: Build release version
    cmds:
      - cargo build --release

  test:
    desc: Run tests
    cmds:
      - cargo test

  test-debug:
    desc: Run tests with debug logging
    cmds:
      - RUST_LOG=debug cargo test

  test-trace:
    desc: Run tests with trace logging for parser
    cmds:
      - RUST_LOG=panache::parser=trace cargo test

  test-quiet:
    desc: Run tests quietly (no debug output)
    cmds:
      - RUST_LOG=off cargo test

  dev:
    desc: Development workflow - check, test, lint
    cmds:
      - cargo check
      - cargo test
      - cargo clippy --all-targets --all-features -- -D warnings

  docs-preview:
    desc: Preview documentation site locally
    cmds:
      - cd docs && quarto preview --no-browser

  wasm-build:
    desc: Build panache-wasm for web playground
    cmds:
      - cd crates/panache-wasm && wasm-pack build --target web
      - cp -r crates/panache-wasm/pkg docs/playground/
      - rm -rf docs/playground/pkg/.gitignore

  playground-serve:
    desc: Serve playground locally
    cmds:
      - cd docs/playground && python3 -m http.server

  update-golden-expected:
    desc: Update expected golden test outputs
    cmds:
      - UPDATE_EXPECTED=1 cargo test --test golden_cases

  update-golden-cst:
    desc: Update golden test CST files
    cmds:
      - UPDATE_CST=1 cargo test --test golden_cases

  coverage:
    desc: Generate code coverage report
    cmds:
      - cargo llvm-cov --all-features --workspace --html
      - echo "Coverage report generated at target/llvm-cov/html/index.html"

  coverage-open:
    desc: Generate and open coverage report in browser
    cmds:
      - cargo llvm-cov --all-features --workspace --open
