simdutf8-cli 0.2.7

SIMD-accelerated UTF-8 validation CLI built on the simdutf8 crate, with hardened path handling.
Documentation
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2025,2026 ndaal Gesellschaft für Sicherheit in der Informationstechnik mbH & Co KG, Cologne
// SPDX-FileCopyrightText: Author: Pierre Gronau <Pierre.Gronau@ndaal.eu>

//! Binary entry point for `simdutf8-cli`.
//!
//! All real work lives in the library crate (`simdutf8_cli`); this file only
//! parses arguments, wires up locked stdout/stderr and maps the resulting exit
//! code onto a [`std::process::ExitCode`]. No `unsafe` and no panicking I/O.

#![forbid(unsafe_code)]

use std::io::Write;
use std::process::ExitCode;

use clap::Parser;
use simdutf8_cli::cli::{self, Args};

fn main() -> ExitCode {
    let args = Args::parse();

    let stdout = std::io::stdout();
    let stderr = std::io::stderr();
    let mut out = stdout.lock();
    let mut err = stderr.lock();

    let code = match cli::run(&args, &mut out, &mut err) {
        Ok(code) => code,
        Err(io_err) => {
            // Writing to stdout failed (e.g. a closed pipe); report and exit 2.
            let _ = writeln!(err, "error: {io_err}");
            2
        },
    };

    let _ = out.flush();
    let _ = err.flush();
    ExitCode::from(code)
}