anyrepair 0.2.4

A comprehensive Rust crate for repairing malformed structured data including JSON, YAML, XML, TOML, CSV, INI, Markdown, and Diff with format auto-detection
Documentation
//! CLI module for anyrepair
//!
//! Provides command handlers for the CLI interface

pub mod repair_cmd;
pub mod validate_cmd;
pub mod batch_cmd;
pub mod stream_cmd;

use std::fs;
use std::io::{self, Read};

/// Read content from file or stdin
pub fn read_input(file_path: Option<&str>) -> io::Result<String> {
    match file_path {
        Some(path) => fs::read_to_string(path),
        None => {
            let mut buffer = String::new();
            io::stdin().read_to_string(&mut buffer)?;
            Ok(buffer)
        }
    }
}

/// Write content to file or stdout
pub fn write_output(content: &str, file_path: Option<&str>) -> io::Result<()> {
    match file_path {
        Some(path) => fs::write(path, content),
        None => {
            print!("{}", content);
            Ok(())
        }
    }
}