Rename cargo.rs
into rust_tools.rs
to prepare the addition of the rustc
command
This commit is contained in:
parent
75f0ab5c55
commit
5eb8d854d1
@ -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(),
|
||||
|
@ -8,32 +8,36 @@ use std::collections::HashMap;
|
||||
use std::ffi::OsStr;
|
||||
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.
|
||||
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::<Vec<_>>();
|
||||
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(()),
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user