mod args;
mod commands {
    automod::dir!(pub "src/commands");
}
mod util;

use clap::{Parser, Subcommand};

#[derive(Parser)]
#[command(name = "eure", about = "Eure file utilities")]
struct Cli {
    #[command(subcommand)]
    command: Commands,
}

#[derive(Subcommand)]
enum Commands {
    /// Parse and display Eure file syntax tree
    Inspect(commands::inspect::Args),
    /// Unformat Eure file
    Unformat(commands::unformat::Args),
    /// Format Eure file
    Fmt(commands::fmt::Args),
    /// Convert Eure to JSON
    ToJson(commands::to_json::Args),
    /// Convert JSON to Eure
    FromJson(commands::from_json::Args),
    /// Convert TOML to Eure
    FromToml(commands::from_toml::Args),
    /// Syntax highlight Eure file with colors
    Highlight(commands::highlight::Args),
    /// Export Eure file as HTML with syntax highlighting
    Html(commands::html::Args),
    /// Validate Eure file against a schema
    Check(commands::check::Args),
    /// Eure Markdown document commands
    Mark(commands::mark::Args),
    /// Manage remote schema cache
    Cache(commands::cache::Args),
}

fn main() {
    let cli = Cli::parse();

    match cli.command {
        Commands::Inspect(args) => commands::inspect::run(args),
        Commands::Unformat(args) => commands::unformat::run(args),
        Commands::Fmt(args) => commands::fmt::run(args),
        Commands::ToJson(args) => commands::to_json::run(args),
        Commands::FromJson(args) => commands::from_json::run(args),
        Commands::FromToml(args) => commands::from_toml::run(args),
        Commands::Highlight(args) => commands::highlight::run(args),
        Commands::Html(args) => commands::html::run(args),
        Commands::Check(args) => commands::check::run(args),
        Commands::Mark(args) => commands::mark::run(args),
        Commands::Cache(args) => commands::cache::run(args),
    }
}
