Rename cargo.rs into rust_tools.rs to prepare the addition of the rustc command
This commit is contained in:
@@ -2,12 +2,12 @@ use std::env;
|
|||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
mod build;
|
mod build;
|
||||||
mod cargo;
|
|
||||||
mod clean;
|
mod clean;
|
||||||
mod clone_gcc;
|
mod clone_gcc;
|
||||||
mod config;
|
mod config;
|
||||||
mod info;
|
mod info;
|
||||||
mod prepare;
|
mod prepare;
|
||||||
|
mod rust_tools;
|
||||||
mod rustc_info;
|
mod rustc_info;
|
||||||
mod test;
|
mod test;
|
||||||
mod utils;
|
mod utils;
|
||||||
@@ -75,7 +75,7 @@ fn main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = match command {
|
if let Err(e) = match command {
|
||||||
Command::Cargo => cargo::run(),
|
Command::Cargo => rust_tools::run_cargo(),
|
||||||
Command::Clean => clean::run(),
|
Command::Clean => clean::run(),
|
||||||
Command::Prepare => prepare::run(),
|
Command::Prepare => prepare::run(),
|
||||||
Command::Build => build::run(),
|
Command::Build => build::run(),
|
||||||
|
|||||||
@@ -8,32 +8,36 @@ use std::collections::HashMap;
|
|||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn args() -> Result<Option<Vec<String>>, String> {
|
fn args(command: &str) -> Result<Option<Vec<String>>, String> {
|
||||||
// We skip the binary and the "cargo" option.
|
// We skip the binary and the "cargo" option.
|
||||||
if let Some("--help") = std::env::args().skip(2).next().as_deref() {
|
if let Some("--help") = std::env::args().skip(2).next().as_deref() {
|
||||||
usage();
|
usage(command);
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
let args = std::env::args().skip(2).collect::<Vec<_>>();
|
let args = std::env::args().skip(2).collect::<Vec<_>>();
|
||||||
if args.is_empty() {
|
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))
|
Ok(Some(args))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() {
|
fn usage(command: &str) {
|
||||||
println!(
|
println!(
|
||||||
r#"
|
r#"
|
||||||
`cargo` command help:
|
`{}` command help:
|
||||||
|
|
||||||
[args] : Arguments to be passed to the cargo command
|
[args] : Arguments to be passed to the cargo command
|
||||||
--help : Show this help
|
--help : Show this help
|
||||||
"#
|
"#,
|
||||||
|
command,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run() -> Result<(), String> {
|
pub fn run_cargo() -> Result<(), String> {
|
||||||
let args = match args()? {
|
let args = match args("cargo")? {
|
||||||
Some(a) => a,
|
Some(a) => a,
|
||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user