rust_checker 1.0.0

A modular Rust code validation tool with HTML, JSON, SVG badge, and JUnit XML report export. Includes optional web dashboard and PQC guardrails via plugins.
Documentation
use std::fs;
use std::io::Write;
use std::path::Path;

fn main() {
    let hook_path = Path::new(".git/hooks/pre-commit");

    let script = r#"#!/bin/sh
echo "🔍 Running rust_checker before commit..."
cargo run -- . || {
    echo " rust_checker validation failed. Commit aborted."
    exit 1
}
"#;

    if let Some(parent) = hook_path.parent() {
        fs::create_dir_all(parent).expect("Failed to create hooks directory");
    }

    let mut file = fs::File::create(hook_path).expect("Failed to create pre-commit hook");
    file.write_all(script.as_bytes())
        .expect("Failed to write pre-commit script");

    // Make executable on Unix; no-op on Windows
    #[cfg(unix)]
    {
        use std::os::unix::fs::PermissionsExt;
        let mut perms = fs::metadata(hook_path)
            .expect("Failed to read permissions")
            .permissions();
        perms.set_mode(0o755); // executable
        fs::set_permissions(hook_path, perms).expect("Failed to set executable permissions");
    }

    println!(" Git pre-commit hook installed successfully.");
}