Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/edda

crates/nornir-git/examples/fleet_survey.rs

//! `cargo run -p nornir-git --example fleet_survey -- [ROOT]`
//!
//! Print one row per checkout under `ROOT` (default: the current directory's
//! parent-of-repos, i.e. the argument you almost always want to pass) and a
//! verdict line naming the ratio.
//!
//! This is the smallest real driver for [`nornir_git::fleet`] — the door that
//! makes the sweep runnable without waiting on a full CLI build. The nornir verb
//! calls the same [`nornir_git::fleet::survey_root`]; there is one implementation
//! and this example is not a second one.
//!
//! Exit code is 1 when any checkout is not FIT, so it works as a guard in a
//! script and not only as a report.

fn main() {
    let root = std::env::args()
        .nth(1)
        .unwrap_or_else(|| ".".to_string());
    let rows = match nornir_git::fleet::survey_root(std::path::Path::new(&root)) {
        Ok(r) => r,
        Err(e) => {
            eprintln!("fleet: {e:#}");
            std::process::exit(2);
        }
    };
    print!("{}", nornir_git::fleet::report(&rows));
    if rows.iter().any(|r| !r.fit()) {
        std::process::exit(1);
    }
}