//! Project automation for Lutra, run as `cargo xtask `. //! //! Every subcommand prints what it checks and exits with status 1 and a //! message when the check fails. mod assets; mod cleanroom; mod layers; mod licences; mod lints; mod tasks; mod util; use std::process::ExitCode; /// Usage text printed for `help` and unknown subcommands. const USAGE: &str = "usage: cargo xtask commands: ci [--skip-ui] the full quality gate (run before every commit) layers check the crate layering assets check that every asset has a row in ASSETS.md cleanroom check for JetBrains copyright notices and exported configuration ui-licences check the licences of the frontend's production dependencies lints-selftest prove that shipped unwrap() fails clippy and test unwrap() passes dev [-- ARGS] run the desktop app in development mode, ARGS go to the app fixtures create Symfony and Laravel reference projects in target/fixtures/"; /// Dispatches to the subcommand named by the first argument. fn main() -> ExitCode { let args: Vec = std::env::args().skip(1).collect(); let Some((command, rest)) = args.split_first() else { println!("{USAGE}"); return ExitCode::SUCCESS; }; let result = match command.as_str() { "ci" => tasks::ci(rest.iter().any(|a| a == "--skip-ui")), "layers" => layers::check_workspace(), "assets" => assets::check_repo(), "cleanroom" => cleanroom::check_repo(), "ui-licences" => licences::check_ui(), "lints-selftest" => lints::selftest(), "dev" => { let app_args: Vec = rest .iter() .skip_while(|a| *a != "--") .skip(1) .cloned() .collect(); tasks::dev(&app_args) } "fixtures" => tasks::fixtures(), "help" | "--help" | "-h" => { println!("{USAGE}"); Ok(()) } other => Err(format!("unknown command `{other}`\n\n{USAGE}")), }; match result { Ok(()) => ExitCode::SUCCESS, Err(message) => { eprintln!("xtask: {message}"); ExitCode::FAILURE } } }