# ╔══════════════════════════════════════════════════════════════════════╗
# ║                   SHARED VARIABLES AND HELPERS                       ║
# ║                     TypeDialog workspace                             ║
# ╚══════════════════════════════════════════════════════════════════════╝

# === WORKSPACE STRUCTURE ===
WORKSPACE_ROOT := justfile_directory()
CRATES := "typedialog-core typedialog typedialog-tui typedialog-web"
CORE_CRATE := "crates/typedialog-core"

# === FEATURE FLAGS ===
FEATURES_CLI := "cli,i18n,templates"
FEATURES_TUI := "tui,i18n,templates"
FEATURES_WEB := "web,i18n,templates"
FEATURES_FULL := "cli,tui,web,i18n,templates"
FEATURES_ALL_BACKENDS := "cli,tui,web"

# === BUILD PROFILES ===
PROFILE_DEBUG := "debug"
PROFILE_RELEASE := "release"

# === CARGO COMMANDS ===
CARGO_CHECK := "cargo check --workspace"
CARGO_BUILD := "cargo build --workspace"
CARGO_TEST := "cargo test --workspace"
CARGO_CLIPPY := "cargo clippy --all-targets --all-features -- -D warnings"
CARGO_FMT := "cargo fmt --all"
CARGO_FMT_CHECK := "cargo fmt --all -- --check"

# === HELPERS ===

# Print section header
header MSG:
    @echo "=== {{ MSG }} ==="

# Print success message
success MSG:
    @echo "✓ {{ MSG }}"

# Print warning message
warn MSG:
    @echo "⚠ {{ MSG }}"

# Print error message
error MSG:
    @echo "✗ {{ MSG }}"

# Check cargo is available
_check_cargo:
    @command -v cargo >/dev/null || (echo "cargo not found" && exit 1)

# Validate workspace structure
_validate_workspace:
    @[ -f "{{ WORKSPACE_ROOT }}/Cargo.toml" ] || (echo "Cargo.toml not found" && exit 1)
    @just header "Workspace validation"
    @echo "Root: {{ WORKSPACE_ROOT }}"
    @echo "Crates: {{ CRATES }}"
    @just success "Workspace valid"
