xacli 0.2.1

A modern, developer-friendly CLI framework for Rust
Documentation
//! XaCLI command-line tool
//!
//! This binary provides tooling for XaCLI projects including:
//! - Documentation generation (converting .xacli.hcl to VHS tapes and GIFs)
//! - Test execution (running test suites with various output formats)
//!
//! # Installation
//!
//! ```bash
//! cargo install xacli --features cli
//! ```
//!
//! # Usage
//!
//! ```bash
//! xacli --help
//! xacli doc build ./specs
//! xacli test report --format terminal
//! ```

#![allow(dead_code)]

mod commands;

use xacli::derive::{App, Command};
use xacli::Context;

// ============================================================================
// Application Definition
// ============================================================================

/// XaCLI - A modern CLI framework tooling
#[derive(App)]
#[app(
    name = "xacli",
    version = "0.2.1",
    title = "XaCLI",
    description = "A modern, developer-friendly CLI framework tooling"
)]
struct XacliApp {
    /// Available commands
    #[command(subcommands)]
    commands: XacliCommands,
}

// ============================================================================
// Top-Level Commands
// ============================================================================

/// Available commands
#[derive(Command)]
enum XacliCommands {
    /// Documentation tooling
    Doc(DocCmd),
    /// Test report commands
    Test(TestCmd),
}

// ============================================================================
// Doc Command
// ============================================================================

/// Documentation tooling commands
#[derive(Command)]
#[command(description = "Documentation tooling commands")]
struct DocCmd {
    /// Doc subcommands
    #[command(subcommands)]
    action: DocActions,
}

/// Doc subcommands
#[derive(Command)]
enum DocActions {
    /// Build documentation from .xacli.hcl files
    Build(DocBuildCmd),
}

/// Convert .xacli.hcl specification files to VHS tape format and generate GIFs
#[derive(Command)]
#[command(
    name = "build",
    description = "Convert .xacli.hcl specification files to VHS tape format"
)]
struct DocBuildCmd {
    /// Directory to search for .xacli.hcl files
    #[arg(positional)]
    directory: bool,
}

impl DocBuildCmd {
    fn run(&self, ctx: &mut dyn Context) -> xacli::Result<()> {
        commands::doc::build_command(ctx)
    }
}

// ============================================================================
// Test Command
// ============================================================================

/// Test report commands
#[derive(Command)]
#[command(description = "Test report commands")]
struct TestCmd {
    /// Test subcommands
    #[command(subcommands)]
    action: TestActions,
}

/// Test subcommands
#[derive(Command)]
enum TestActions {
    /// Display test report
    Report(TestReportCmd),
}

/// Display test report from .xacli/reports/
#[derive(Command)]
#[command(
    name = "report",
    description = "Display test report from .xacli/reports/"
)]
struct TestReportCmd {
    /// Output format: terminal (default), json, or junit
    #[arg(long = "format", short = 'f')]
    format: bool,

    /// Input report file path
    #[arg(long = "input", short = 'i')]
    input: bool,
}

impl TestReportCmd {
    fn run(&self, ctx: &mut dyn Context) -> xacli::Result<()> {
        commands::test::report_command(ctx)
    }
}

// ============================================================================
// Main Entry Point
// ============================================================================

fn main() {
    if let Err(e) = XacliApp::execute() {
        eprintln!("Error: {}", e);
        std::process::exit(2);
    }
}