diff --git a/build_system/src/main.rs b/build_system/src/main.rs index 48ffbc7a907..99d466f2b86 100644 --- a/build_system/src/main.rs +++ b/build_system/src/main.rs @@ -2,12 +2,12 @@ use std::env; use std::process; mod build; -mod cargo; mod clean; mod clone_gcc; mod config; mod info; mod prepare; +mod rust_tools; mod rustc_info; mod test; mod utils; @@ -75,7 +75,7 @@ fn main() { }; if let Err(e) = match command { - Command::Cargo => cargo::run(), + Command::Cargo => rust_tools::run_cargo(), Command::Clean => clean::run(), Command::Prepare => prepare::run(), Command::Build => build::run(), diff --git a/build_system/src/cargo.rs b/build_system/src/rust_tools.rs similarity index 89% rename from build_system/src/cargo.rs rename to build_system/src/rust_tools.rs index e4ea79b06f2..80885d0c6c7 100644 --- a/build_system/src/cargo.rs +++ b/build_system/src/rust_tools.rs @@ -8,32 +8,36 @@ use std::collections::HashMap; use std::ffi::OsStr; use std::path::PathBuf; -fn args() -> Result>, String> { +fn args(command: &str) -> Result>, String> { // We skip the binary and the "cargo" option. if let Some("--help") = std::env::args().skip(2).next().as_deref() { - usage(); + usage(command); return Ok(None); } let args = std::env::args().skip(2).collect::>(); if args.is_empty() { - return Err("Expected at least one argument for `cargo` subcommand, found none".to_string()); + return Err(format!( + "Expected at least one argument for `{}` subcommand, found none", + command + )); } Ok(Some(args)) } -fn usage() { +fn usage(command: &str) { println!( r#" -`cargo` command help: +`{}` command help: [args] : Arguments to be passed to the cargo command --help : Show this help -"# +"#, + command, ) } -pub fn run() -> Result<(), String> { - let args = match args()? { +pub fn run_cargo() -> Result<(), String> { + let args = match args("cargo")? { Some(a) => a, None => return Ok(()), };