main.rs (1311B)
1 use harvestcircle_xtask::{Command, run}; 2 use std::env; 3 use std::process::ExitCode; 4 5 fn main() -> ExitCode { 6 let mut arguments = env::args().skip(1); 7 let Some(command) = arguments.next() else { 8 eprintln!( 9 "usage: cargo run --manifest-path tools/xtask/Cargo.toml -- <design-source-audit|repo-audit|namespace-audit|provenance-check|qualification-report>" 10 ); 11 return ExitCode::FAILURE; 12 }; 13 if arguments.next().is_some() { 14 eprintln!("xtask commands do not accept positional arguments"); 15 return ExitCode::FAILURE; 16 } 17 let command = match command.parse::<Command>() { 18 Ok(command) => command, 19 Err(message) => { 20 eprintln!("{message}"); 21 return ExitCode::FAILURE; 22 } 23 }; 24 let root = match env::current_dir() { 25 Ok(root) => root, 26 Err(error) => { 27 eprintln!("unable to resolve the HarvestCircle repository root: {error}"); 28 return ExitCode::FAILURE; 29 } 30 }; 31 match run(&root, command) { 32 Ok(report) => { 33 print!("{report}"); 34 ExitCode::SUCCESS 35 } 36 Err(findings) => { 37 for finding in findings { 38 eprintln!("{finding}"); 39 } 40 ExitCode::FAILURE 41 } 42 } 43 }