pub mod commands;
pub mod output;
use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(
name = "scipix-cli",
version,
about = "A Rust-based CLI for Scipix OCR processing",
long_about = "Process images with OCR, extract mathematical formulas, and convert to LaTeX or other formats.\n\n\
Supports single file processing, batch operations, and API server mode."
)]
pub struct Cli {
#[arg(
short,
long,
global = true,
env = "MATHPIX_CONFIG",
help = "Path to configuration file"
)]
pub config: Option<PathBuf>,
#[arg(
short,
long,
global = true,
help = "Enable verbose logging (DEBUG level)"
)]
pub verbose: bool,
#[arg(
short,
long,
global = true,
conflicts_with = "verbose",
help = "Suppress all non-error output"
)]
pub quiet: bool,
#[arg(
short,
long,
global = true,
default_value = "text",
help = "Output format for results"
)]
pub format: OutputFormat,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Ocr(commands::ocr::OcrArgs),
Batch(commands::batch::BatchArgs),
Serve(commands::serve::ServeArgs),
Mcp(commands::mcp::McpArgs),
Config(commands::config::ConfigArgs),
Doctor(commands::doctor::DoctorArgs),
Version,
Completions {
#[arg(value_enum)]
shell: Option<clap_complete::Shell>,
},
}
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
pub enum OutputFormat {
Text,
Json,
Latex,
Markdown,
MathMl,
}
impl std::fmt::Display for OutputFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
OutputFormat::Text => write!(f, "text"),
OutputFormat::Json => write!(f, "json"),
OutputFormat::Latex => write!(f, "latex"),
OutputFormat::Markdown => write!(f, "markdown"),
OutputFormat::MathMl => write!(f, "mathml"),
}
}
}