use std::process::ExitCode;

const VERSION: &str = env!("CARGO_PKG_VERSION");

fn main() -> ExitCode {
    let args: Vec<String> = std::env::args().collect();

    if args.len() > 1 && (args[1] == "--version" || args[1] == "-V") {
        println!("axe {VERSION} (spec 1.0)");
        return ExitCode::SUCCESS;
    }

    if args.len() > 1 && (args[1] == "--help" || args[1] == "-h") {
        print_help();
        return ExitCode::SUCCESS;
    }

    if args.len() > 1 && args[1] == "targets" {
        print_targets();
        return ExitCode::SUCCESS;
    }

    eprintln!("axe {VERSION} — Agent eXtension Engine");
    eprintln!();
    eprintln!("Not yet implemented. See https://github.com/claylo/axe");
    eprintln!();
    eprintln!("Run `axe --help` for usage.");
    ExitCode::FAILURE
}

fn print_help() {
    println!(
        "\
axe {VERSION} — Agent eXtension Engine

Compile agent skills and rules across agentic coding platforms.

USAGE:
    axe <COMMAND>

COMMANDS:
    build       Compile AXE source to target platform(s)
    compat      Reverse-compile vendor format to AXE IR, then forward-compile
    inspect     Parse and display IR for an AXE source or vendor file
    init        Scaffold a new AXE extension
    validate    Check an AXE source for errors
    diagnose    Show what will be lossy/shimmed for each target
    targets     List supported target platforms and their capabilities

OPTIONS:
    -h, --help       Print help
    -V, --version    Print version (includes spec version)

EXAMPLES:
    axe build --target claude,cursor,codex .
    axe compat --from cursor --to claude .cursor/rules/deploy.mdc
    axe diagnose --target windsurf .

SPEC:
    AXE Specification v1.0
    https://github.com/axe-spec/spec"
    );
}

fn print_targets() {
    println!(
        "\
Supported targets (axe {VERSION}, spec 1.0):

  claude      Claude Code (.claude/skills/, CLAUDE.md, hooks, plugins)
  cursor      Cursor (.cursor/rules/, AGENTS.md, commands)
  codex       OpenAI Codex (.codex/skills/, AGENTS.md, config.toml)
  gemini      Gemini CLI (.gemini/, GEMINI.md, extensions, hooks)
  copilot     GitHub Copilot (.github/, copilot-instructions.md, hooks)
  cline       Cline (.clinerules/, workflows, hooks)
  windsurf    Windsurf (.windsurf/rules/, hooks)
  continue    Continue (.continue/, config.yaml, rules)
  zed         Zed (.zed/, .rules, extensions)
  aider       Aider (CONVENTIONS.md — limited target, no hooks/vars)"
    );
}
