feat: CommandError -> CommandResult, add git check
This commit is contained in:
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use std::time::Duration;
|
||||
use clap::{ArgMatches, SubCommand, App, Arg};
|
||||
use crates_io_api::{SyncClient, CrateResponse};
|
||||
use crate::cmd::{Command, CommandError};
|
||||
use crate::cmd::{Command, CommandResult};
|
||||
|
||||
pub struct CommandImpl;
|
||||
|
||||
@@ -16,7 +16,7 @@ impl Command for CommandImpl {
|
||||
.arg(Arg::with_name("add").short("A").long("add").multiple(true).takes_value(true).help("Add crates to project"))
|
||||
}
|
||||
|
||||
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
||||
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandResult {
|
||||
let crate_io_client = SyncClient::new(
|
||||
"cargotool (https://hatter.me/)", Duration::from_millis(1000)
|
||||
)?;
|
||||
@@ -24,13 +24,13 @@ impl Command for CommandImpl {
|
||||
let toml_str = match fs::read_to_string("Cargo.toml") {
|
||||
Ok(s) => s, Err(e) => {
|
||||
failure!("Read file Cargo.toml failed: {}", e);
|
||||
return Ok(());
|
||||
return Ok(-1);
|
||||
},
|
||||
};
|
||||
let mut toml: toml::Value = match toml_str.parse() {
|
||||
Ok(t) => t, Err(e) => {
|
||||
failure!("Parse Cargo.toml failed: {}", e);
|
||||
return Ok(());
|
||||
return Ok(-1);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -83,7 +83,7 @@ impl Command for CommandImpl {
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user