Skip to content

Commit 5eb8d85

Browse files
Rename cargo.rs into rust_tools.rs to prepare the addition of the rustc command
1 parent 75f0ab5 commit 5eb8d85

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

build_system/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ use std::env;
22
use std::process;
33

44
mod build;
5-
mod cargo;
65
mod clean;
76
mod clone_gcc;
87
mod config;
98
mod info;
109
mod prepare;
10+
mod rust_tools;
1111
mod rustc_info;
1212
mod test;
1313
mod utils;
@@ -75,7 +75,7 @@ fn main() {
7575
};
7676

7777
if let Err(e) = match command {
78-
Command::Cargo => cargo::run(),
78+
Command::Cargo => rust_tools::run_cargo(),
7979
Command::Clean => clean::run(),
8080
Command::Prepare => prepare::run(),
8181
Command::Build => build::run(),

build_system/src/cargo.rs renamed to build_system/src/rust_tools.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,36 @@ use std::collections::HashMap;
88
use std::ffi::OsStr;
99
use std::path::PathBuf;
1010

11-
fn args() -> Result<Option<Vec<String>>, String> {
11+
fn args(command: &str) -> Result<Option<Vec<String>>, String> {
1212
// We skip the binary and the "cargo" option.
1313
if let Some("--help") = std::env::args().skip(2).next().as_deref() {
14-
usage();
14+
usage(command);
1515
return Ok(None);
1616
}
1717
let args = std::env::args().skip(2).collect::<Vec<_>>();
1818
if args.is_empty() {
19-
return Err("Expected at least one argument for `cargo` subcommand, found none".to_string());
19+
return Err(format!(
20+
"Expected at least one argument for `{}` subcommand, found none",
21+
command
22+
));
2023
}
2124
Ok(Some(args))
2225
}
2326

24-
fn usage() {
27+
fn usage(command: &str) {
2528
println!(
2629
r#"
27-
`cargo` command help:
30+
`{}` command help:
2831
2932
[args] : Arguments to be passed to the cargo command
3033
--help : Show this help
31-
"#
34+
"#,
35+
command,
3236
)
3337
}
3438

35-
pub fn run() -> Result<(), String> {
36-
let args = match args()? {
39+
pub fn run_cargo() -> Result<(), String> {
40+
let args = match args("cargo")? {
3741
Some(a) => a,
3842
None => return Ok(()),
3943
};

0 commit comments

Comments
 (0)