toon_validate_cli/
lib.rs

1//! toon-validate-cli
2//! 
3//! Command-line interface for TOON validation and analysis.
4
5mod analyze;
6mod check;
7mod commands;
8mod profile;
9
10use anyhow::Result;
11use clap::Parser;
12use commands::{Cli, Commands};
13use std::process;
14
15/// Main entry point for the CLI
16pub fn main() {
17    if let Err(e) = run() {
18        eprintln!("Error: {:#}", e);
19        process::exit(1);
20    }
21}
22
23fn run() -> Result<()> {
24    let cli = Cli::parse();
25    
26    match cli.command {
27        Commands::Analyze { path, format, json } => {
28            let input_format = format.map(|f| f.to_input_format());
29            analyze::analyze_file(&path, input_format, json)?;
30        }
31        Commands::Profile {
32            dir,
33            extensions,
34            format,
35            json,
36        } => {
37            let input_format = format.map(|f| f.to_input_format());
38            profile::profile_directory(&dir, extensions, input_format, json)?;
39        }
40        Commands::Check { path, format, json } => {
41            let input_format = format.map(|f| f.to_input_format());
42            check::check_file(&path, input_format, json)?;
43        }
44    }
45    
46    Ok(())
47}