# ╔══════════════════════════════════════════════════════════════════════╗
# ║                    TypeDialog - Justfile                              ║
# ║                   Modular workspace orchestration                     ║
# ║                    Features: CLI, TUI, Web, i18n                      ║
# ╚══════════════════════════════════════════════════════════════════════╝

# Import feature-specific modules (only used modules)
mod build "justfiles/build.just"    # Build recipes (CLI, TUI, Web)
mod test "justfiles/test.just"      # Test suite (unit, integration, docs)
mod dev "justfiles/dev.just"        # Development tools (fmt, lint, watch, docs)
mod ci "justfiles/ci.just"          # CI/CD pipeline (validate, test, build)
mod distro "justfiles/distro.just"  # Distribution & packaging (release, cross-compile)
mod nickel "justfiles/nickel.just"  # Nickel integration (schema → form generation)

# === SHARED VARIABLES ===
# WORKSPACE_ROOT := justfile_directory()
# CRATES := "typedialog-core typedialog typedialog-tui typedialog-web"

# === ORCHESTRATION RECIPES ===

# Default: show available commands
default:
    @just --list

# Full development workflow
[doc("Run check + fmt + lint (all languages) + test")]
check-all:
    @just dev::fmt-check
    @just dev::lint-all
    @just test::all

# Full CI workflow (format + lint + test + build all variants)
[doc("Complete CI pipeline: format + lint + test + build")]
ci-full:
    @just ci::check
    @just ci::test-all
    @just build::all

# Quick start development environment
[doc("Quick dev setup: build default + start watching")]
dev-start:
    @just dev::build
    @just dev::watch

# === MODULAR HELP ===

# Show help by module: just help build, just help test, etc
[doc("Show help for a specific module")]
help MODULE="":
    @if [ -z "{{ MODULE }}" ]; then \
        echo "TYPEDIALOG - MODULAR JUSTFILE HELP"; \
        echo ""; \
        echo "Available modules:"; \
        echo "  just help build     Build commands"; \
        echo "  just help test      Test commands"; \
        echo "  just help dev       Development utilities"; \
        echo "  just help ci        CI/CD pipeline"; \
        echo "  just help distro    Distribution & packaging"; \
        echo ""; \
        echo "Orchestration:"; \
        echo "  just check-all      Format check + lint + test"; \
        echo "  just ci-full        Full CI pipeline"; \
        echo "  just dev-start      Quick dev setup"; \
        echo ""; \
        echo "Use: just help <module> for details"; \
    elif [ "{{ MODULE }}" = "build" ]; then \
        just build::help; \
    elif [ "{{ MODULE }}" = "test" ]; then \
        just test::help; \
    elif [ "{{ MODULE }}" = "dev" ]; then \
        just dev::help; \
    elif [ "{{ MODULE }}" = "ci" ]; then \
        just ci::help; \
    elif [ "{{ MODULE }}" = "distro" ]; then \
        just distro::help; \
    else \
        echo "Unknown module: {{ MODULE }}"; \
        echo "Available: build, test, dev, ci, distro"; \
    fi
