xmlformat 1.2.1

Basic XML raw text or files formatter. Use it as a dependency or install it as a binary.
Documentation
#[cfg(feature = "bin-deps")]
use std::path::PathBuf;

#[cfg(feature = "bin-deps")]
use anyhow::Result;

#[cfg(feature = "bin-deps")]
use clap::Parser;

#[cfg(feature = "bin-deps")]
use xmlformat::Formatter;

#[cfg(feature = "bin-deps")]
#[derive(Parser)]
struct Cli {
    #[arg(short, long)]
    file: Option<PathBuf>,
    #[arg(short, long)]
    compress: bool,
    #[arg(short, long, default_value_t = 2)]
    indent: usize,
    #[arg(short, long)]
    keep_comments: bool,
    #[arg(short, long)]
    eof_newline: bool,
}

#[cfg(feature = "bin-deps")]
fn main() -> Result<()> {
    let cli = Cli::parse();

    let formatter = Formatter {
        compress: cli.compress,
        indent: cli.indent,
        keep_comments: cli.keep_comments,
        eof_newline: cli.eof_newline,
    };

    let result = if let Some(file_path) = cli.file {
        formatter.format_file(file_path)?
    } else {
        formatter.format_stdin()?
    };

    print!("{}", result);
    Ok(())
}

#[cfg(not(feature = "bin-deps"))]
fn main() {
    eprintln!("The binary requires the `bin-deps` feature. Run with:");
    eprintln!("    cargo run --features bin-deps");
}