# Help Commands Module
# Centralized help system for all commands and modules

# Set shell for commands
set shell := ["bash", "-c"]

# Show main help menu (default)
main:
    @echo "  "
    @echo "📖 RUSTELO             help"
    @just logo
    @echo "🚀 Development         help::dev"
    @echo "🔨 Build               help::build"
    @echo "🧪 Testing             help::test"
    @echo "🗄️ Database            help::db"
    @echo "📚 Documentation       help::docs"
    @echo "🔧 Utilities           help::utils"
    @echo "🛠️ Tools               help::tools"
    @echo "🗄️ Build Cache         help::cache"
    @echo "🧩 Modules             help::modules"
    @echo "📖 Complete Reference  help::all"
    @echo ""

# Show help for development commands
dev:
    @echo "🚀 Development Commands:"
    @echo "  start         - Start development server (full build)"
    @echo "  dev-fast      - Fast dev server (smart CSS, skip docs/scaffolding) [df]"
    @echo "  dev-coordinated - Coordinated dev server (no duplicate builds) [dc]"
    @echo "  dev-minimal   - Ultra-minimal dev server (skip all builds) [dm]"
    @echo "  dev-full      - Dev server with CSS watching"
    @echo ""
    @echo "🏗️ Build Management:"
    @echo "  build-artifacts - Build all artifacts (CSS, docs, scaffolding) [ba]"
    @echo "  build-status  - Show build status and artifact health [bs]"
    @echo "  clean-build-artifacts - Clean build artifacts and markers [ca]"
    @echo ""
    @echo "🎨 Asset Management:"
    @echo "  css-watch     - Watch CSS files"
    @echo "  css-build     - Build CSS files"
    @echo "  content-build - Build localized content"
    @echo "  content-generate - Generate new content"
    @echo ""
    @echo "🧭 SPA Navigation Testing:"
    @echo "  nts           - Start server with navigation API (nav-test-start)"
    @echo "  nt <route>    - Test single route (nav-test)"
    @echo "  ns <from> <to> - Test navigation sequence"
    @echo "  nv            - Validate all routes"
    @echo "  nd            - Open navigation dashboard"
    @echo "  nh            - Navigation testing help"
    @echo ""
    @echo "🛠️ Development Tools:"
    @echo "  server-browser-logs - Start browser tools server for debugging"
    @echo ""
    @echo "💡 Performance Tip: Use 'just dev-fast' for 60-80% faster builds!"
    @echo "📋 Module commands: just dev::<command>"
    @echo "  serve, minimal, verbose, port, source, bundled"
    @echo "  ultra-minimal, dev-fast, dev-coordinated"
    @echo "  manager, info, complete, content-*, deps"
    @echo "  with-nav-test, nav-test-*, nav-help, build-status"

# Show help for build commands
build:
    @echo "🔨 Build Commands:"
    @echo "  build-dev     - Build for development"
    @echo "  build-prod    - Build for production"
    @echo "  serve-prod    - Serve production build"
    @echo "  serve-cms     - Serve with CMS features"
    @echo "  clean         - Clean build artifacts"
    @echo ""
    @echo "📋 Module commands: just build::<command>"
    @echo "  basic, all, serve, features, cargo, cross, docker"

# Show help for testing commands
test:
    @echo "🧪 Testing Commands:"
    @echo "  test-run      - Run all tests"
    @echo "  check         - Check with clippy"
    @echo "  fmt           - Format code"
    @echo "  page-tester   - Test single page in browser"
    @echo "  pages-report  - Generate browser report"
    @echo ""
    @echo "🧭 SPA Navigation Testing:"
    @echo "  nc            - Quick route validation (nav-check)"
    @echo "  na            - Complete navigation test suite"
    @echo "  nb <route>    - Benchmark route performance"
    @echo "  nh            - Navigation testing help (just dev::nav-help)"
    @echo ""
    @echo "📋 Module commands: just test::<command>"
    @echo "  coverage, e2e, specific, watch, quality, audit"
    @echo "📋 SPA Nav Test commands: just dev::<command>"
    @echo "  nav-test-*, nav-quick-check, nav-test-all, nav-help"

# Show help for database commands
db:
    @echo "🗄️ Database Commands:"
    @echo "  db-setup      - Setup database"
    @echo "  db-migrate    - Run migrations"
    @echo ""
    @echo "📋 Module commands: just database::<command>"
    @echo "  create, status, health, reset, backup, restore"

# Show help for documentation commands
docs:
    @echo "📚 Documentation Commands:"
    @echo "  docs-generate - Generate documentation"
    @echo "  docs-build    - Build documentation"
    @echo ""
    @echo "📋 Module commands: just docs::<command>"
    @echo "  serve, book, deploy-*, info-*, workflow"

# Show help for utility commands
utils:
    @echo "🔧 Utility Commands:"
    @echo "  setup         - Complete project setup"
    @echo "  info          - Show project information"
    @echo "  health        - Check application health"
    @echo "  overview      - System overview"
    @echo ""
    @echo "📋 Module commands: just utils::<command>"
    @echo "  config, encrypt, backup, clean-all, scripts-*"

# Show help for tools commands
tools:
    @echo "🛠️ Tools Commands:"
    @echo "  tools-analyze     - Generate project analysis"
    @echo "  tools-manage      - Launch interactive TUI manager"
    @echo "  tools-generate-page - Create new page"
    @echo "  tools-status      - Show tools status"
    @echo "  tools-dev-complete - Complete dev environment"
    @echo ""
    @echo "📋 Module commands: just tools::<command>"
    @echo "  analyze, manage, generate-*, serve, deploy, setup, test"

# Show help for cache commands
cache:
    @just cache::cache-help

# Show help for modules
modules:
    @echo "🧩 Available Modules:"
    @echo "  dev::         - Development server, CSS, content"
    @echo "  build::       - Building, serving, Docker, distribution"
    @echo "  test::        - Testing, quality checks, browser testing"
    @echo "  database::    - Database operations and management"
    @echo "  docs::        - Documentation generation and deployment"
    @echo "  utils::       - Setup, configuration, monitoring, maintenance"
    @echo "  tools::       - Project analysis, code generation, TUI management"
    @echo "  helptext::    - Help system and documentation"
    @echo ""
    @echo "Usage: just <module>::<command>"
    @echo "Example: just dev::serve, just build::prod"
    @echo ""
    @echo "🔍 Quick info: just show <topic> or just sh <topic>"
    @echo "  Topics: info, status, config, overview, aliases, modules, help"

# Show comprehensive help
all:
    @echo "📖 Rustelo - Complete Command Reference"
    @echo ""
    @just helptext::dev
    @echo ""
    @just helptext::build
    @echo ""
    @just helptext::test
    @echo ""
    @just helptext::db
    @echo ""
    @just helptext::docs
    @echo ""
    @just helptext::utils
    @echo ""
    @just helptext::tools
    @echo ""
    @just helptext::modules
    @echo ""
    @echo "For full command list, run: just --list"

# Flexible help command with topic argument
topic TOPIC:
    #!/usr/bin/env bash
    TOPIC="{{TOPIC}}"
    case "$TOPIC" in
        "dev"|"d") just helptext::dev ;;
        "build"|"b") just helptext::build ;;
        "test"|"te") just helptext::test ;;
        "db"|"database") just helptext::db ;;
        "docs"|"documentation"|"doc") just helptext::docs ;;
        "utils"|"utilities"|"u") just helptext::utils ;;
        "tools"| "tls" | "to") just helptext::tools ;;
        "cache"|"c") just helptext::cache ;;
        "modules"|"m") just helptext::modules ;;
        "nav"|"navigation") just dev::nav-help ;;
        "all"|"a") just helptext::all ;;
        *)
            echo "❌ Unknown help topic: $TOPIC"
            echo ""
            echo "Available help topics:"
            echo "  dev, build, test, db, docs, utils, tools, cache, modules, nav, all"
            echo ""
            echo "Usage: just h <topic> or just help-<topic>"
            ;;
    esac

# Show Rustelo logo
logo:
    @echo "  _ "
    @echo " |_)        _  _|_   _   |   _  "
    @echo " | \  |_|  _>   |_  (/_  |  (_) "
    @echo " ______________________________"
    @echo "  "
