chore: reorg
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||||
use openpgp_card::{OpenPgp};
|
|
||||||
use openpgp_card::card_do::{Lang, Sex};
|
use openpgp_card::card_do::{Lang, Sex};
|
||||||
|
use openpgp_card::OpenPgp;
|
||||||
use rust_util::util_clap::{Command, CommandError};
|
use rust_util::util_clap::{Command, CommandError};
|
||||||
|
|
||||||
pub struct CommandImpl;
|
pub struct CommandImpl;
|
||||||
@@ -16,6 +16,7 @@ impl Command for CommandImpl {
|
|||||||
.arg(Arg::with_name("url").long("url").takes_value(true).required(false).help("Set URL"))
|
.arg(Arg::with_name("url").long("url").takes_value(true).required(false).help("Set URL"))
|
||||||
.arg(Arg::with_name("lang").long("lang").takes_value(true).required(false).help("Set lang"))
|
.arg(Arg::with_name("lang").long("lang").takes_value(true).required(false).help("Set lang"))
|
||||||
.arg(Arg::with_name("sex").long("sex").takes_value(true).required(false).help("Set sex, f or m"))
|
.arg(Arg::with_name("sex").long("sex").takes_value(true).required(false).help("Set sex, f or m"))
|
||||||
|
.arg(Arg::with_name("reset").long("reset").help("Reset card"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
||||||
@@ -27,6 +28,13 @@ impl Command for CommandImpl {
|
|||||||
let mut pgp = OpenPgp::new(&mut card);
|
let mut pgp = OpenPgp::new(&mut card);
|
||||||
let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}");
|
let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}");
|
||||||
|
|
||||||
|
if sub_arg_matches.is_present("reset") {
|
||||||
|
warning!("Start reset card...");
|
||||||
|
opt_result!(trans.factory_reset(), "Reset failed: {}");
|
||||||
|
success!("Reset success");
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
|
||||||
opt_result!(trans.verify_pw3(pin.as_ref()), "Admin pin verify failed: {}");
|
opt_result!(trans.verify_pw3(pin.as_ref()), "Admin pin verify failed: {}");
|
||||||
success!("Admin pin verify success!");
|
success!("Admin pin verify success!");
|
||||||
|
|
||||||
@@ -66,8 +74,6 @@ impl Command for CommandImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Upload Key!
|
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ impl Command for CommandImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
||||||
warning!("WORKING!!!");
|
|
||||||
let pin_opt = sub_arg_matches.value_of("pin");
|
let pin_opt = sub_arg_matches.value_of("pin");
|
||||||
let pin = opt_value_result!(pin_opt, "Pin must be assigned");
|
let pin = opt_value_result!(pin_opt, "Pin must be assigned");
|
||||||
if pin.len() < 8 { return simple_error!("Admin pin length:{}, must >= 8!", pin.len()); }
|
if pin.len() < 8 { return simple_error!("Admin pin length:{}, must >= 8!", pin.len()); }
|
||||||
@@ -195,7 +194,7 @@ impl Command for CommandImpl {
|
|||||||
|
|
||||||
let force_make = sub_arg_matches.is_present("force-make");
|
let force_make = sub_arg_matches.is_present("force-make");
|
||||||
if !force_make {
|
if !force_make {
|
||||||
warning!("Force make is OFF, skip write private keys to card!");
|
warning!("Force make is OFF, add argument --force-make to open, skip write private keys to card!");
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user