ruvector_scipix/cli/
mod.rs

1pub mod commands;
2pub mod output;
3
4use clap::{Parser, Subcommand};
5use std::path::PathBuf;
6
7/// Scipix CLI - OCR and mathematical content processing
8#[derive(Parser, Debug)]
9#[command(
10    name = "scipix-cli",
11    version,
12    about = "A Rust-based CLI for Scipix OCR processing",
13    long_about = "Process images with OCR, extract mathematical formulas, and convert to LaTeX or other formats.\n\n\
14                  Supports single file processing, batch operations, and API server mode."
15)]
16pub struct Cli {
17    /// Path to configuration file
18    #[arg(
19        short,
20        long,
21        global = true,
22        env = "MATHPIX_CONFIG",
23        help = "Path to configuration file"
24    )]
25    pub config: Option<PathBuf>,
26
27    /// Enable verbose logging
28    #[arg(
29        short,
30        long,
31        global = true,
32        help = "Enable verbose logging (DEBUG level)"
33    )]
34    pub verbose: bool,
35
36    /// Suppress all non-error output
37    #[arg(
38        short,
39        long,
40        global = true,
41        conflicts_with = "verbose",
42        help = "Suppress all non-error output"
43    )]
44    pub quiet: bool,
45
46    /// Output format (json, text, latex, markdown)
47    #[arg(
48        short,
49        long,
50        global = true,
51        default_value = "text",
52        help = "Output format for results"
53    )]
54    pub format: OutputFormat,
55
56    #[command(subcommand)]
57    pub command: Commands,
58}
59
60#[derive(Subcommand, Debug)]
61pub enum Commands {
62    /// Process a single image or file with OCR
63    Ocr(commands::ocr::OcrArgs),
64
65    /// Process multiple files in batch mode
66    Batch(commands::batch::BatchArgs),
67
68    /// Start the API server
69    Serve(commands::serve::ServeArgs),
70
71    /// Start the MCP (Model Context Protocol) server for AI integration
72    Mcp(commands::mcp::McpArgs),
73
74    /// Manage configuration
75    Config(commands::config::ConfigArgs),
76
77    /// Diagnose environment and optimize configuration
78    Doctor(commands::doctor::DoctorArgs),
79
80    /// Show version information
81    Version,
82
83    /// Generate shell completions
84    Completions {
85        /// Shell to generate completions for (bash, zsh, fish, powershell)
86        #[arg(value_enum)]
87        shell: Option<clap_complete::Shell>,
88    },
89}
90
91#[derive(Debug, Clone, Copy, clap::ValueEnum)]
92pub enum OutputFormat {
93    /// Plain text output
94    Text,
95    /// JSON output
96    Json,
97    /// LaTeX format
98    Latex,
99    /// Markdown format
100    Markdown,
101    /// MathML format
102    MathMl,
103}
104
105impl std::fmt::Display for OutputFormat {
106    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
107        match self {
108            OutputFormat::Text => write!(f, "text"),
109            OutputFormat::Json => write!(f, "json"),
110            OutputFormat::Latex => write!(f, "latex"),
111            OutputFormat::Markdown => write!(f, "markdown"),
112            OutputFormat::MathMl => write!(f, "mathml"),
113        }
114    }
115}