feat: add back --pass argument

This commit is contained in:
2022-03-29 00:29:14 +08:00
parent 4c98af9c01
commit 25edf965e1
6 changed files with 14 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ impl Command for CommandImpl {
fn subcommand<'a>(&self) -> App<'a, 'a> {
SubCommand::with_name(self.name()).about("OpenPGP Card Admin subcommand")
.arg(Arg::with_name("pin").short("p").long("pin").takes_value(true).default_value("12345678").help("OpenPGP card admin pin"))
.arg(Arg::with_name("pass").long("pass").takes_value(true).help("[deprecated] now OpenPGP card admin pin"))
.arg(Arg::with_name("name").short("n").long("name").takes_value(true).required(false).help("Set name"))
.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"))
@@ -17,7 +18,8 @@ impl Command for CommandImpl {
}
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
let pin = opt_value_result!(sub_arg_matches.value_of("pin"), "Pass must be assigned");
let pin_opt = sub_arg_matches.value_of("pass").or(sub_arg_matches.value_of("pin"));
let pin = opt_value_result!(pin_opt, "Pass must be assigned");
if pin.len() < 8 { return simple_error!("Admin pin length:{}, must >= 8!", pin.len()); }
let card_admin = crate::pgpcardutil::get_card_admin(pin)?;