use std::path::PathBuf;
use anyhow::Result;
use clap::Parser;
use ocr::OcrEngine;
#[derive(Parser)]
#[command(name = "ocr-rs", version, about = "A minimalist OCR tool — built from scratch")]
struct Cli {
image_path: PathBuf,
#[arg(short, long, default_value = "text")]
format: String,
#[arg(long)]
preprocess: bool,
}
fn main() -> Result<()> {
let cli = Cli::parse();
let engine = OcrEngine::new().preprocessing(cli.preprocess);
let result = engine.recognize_file(&cli.image_path)?;
match cli.format.as_str() {
"json" => println!("{}", serde_json::to_string_pretty(&result)?),
_ => println!("{}", result.text),
}
Ok(())
}