feat: use rust_util use_clap
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
use crate::cmd::{Command, CommandError};
|
||||
use rust_util::util_clap::{Command, CommandError};
|
||||
use crate::util::{JsonKeyPair, make_key_pair};
|
||||
|
||||
pub struct CommandImpl;
|
||||
@@ -21,12 +21,12 @@ impl Command for CommandImpl {
|
||||
let tag = sub_arg_matches.value_of("tag");
|
||||
if let Ok(_) = File::open(output) {
|
||||
failure!("Output file exists: {}", output);
|
||||
return Ok(());
|
||||
return Ok(None);
|
||||
}
|
||||
let (pri_key, pub_key) = make_key_pair();
|
||||
let json_key_pair = JsonKeyPair::from(pri_key, pub_key, tag.map(|t| t.into()));
|
||||
success!("Write gen key file: {}", output);
|
||||
fs::write(output, json_key_pair.to_json()?.as_bytes())?;
|
||||
Ok(())
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user