feat: update list subcommand
This commit is contained in:
@@ -18,19 +18,26 @@ impl Command for CommandImpl {
|
|||||||
let json_output = sub_arg_matches.is_present("json");
|
let json_output = sub_arg_matches.is_present("json");
|
||||||
if json_output { rust_util::util_msg::set_logger_std_out(false); }
|
if json_output { rust_util::util_msg::set_logger_std_out(false); }
|
||||||
|
|
||||||
let yk = opt_result!(YubiKey::open(), "YubiKey not found: {}");
|
let mut yk = opt_result!(YubiKey::open(), "YubiKey not found: {}");
|
||||||
|
|
||||||
if json_output {
|
if json_output {
|
||||||
let mut json = BTreeMap::<&'_ str, String>::new();
|
let mut json = BTreeMap::<&'_ str, String>::new();
|
||||||
json.insert("name", yk.name().to_string());
|
json.insert("name", yk.name().to_string());
|
||||||
json.insert("version", yk.version().to_string());
|
json.insert("version", yk.version().to_string());
|
||||||
json.insert("serial", yk.serial().0.to_string());
|
json.insert("serial", yk.serial().0.to_string());
|
||||||
|
if let Ok(pin_retries) = yk.get_pin_retries() {
|
||||||
|
json.insert("pin_retries", pin_retries.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
println!("{}", serde_json::to_string_pretty(&json).expect("Convert to JSON failed!"));
|
println!("{}", serde_json::to_string_pretty(&json).expect("Convert to JSON failed!"));
|
||||||
} else {
|
} else {
|
||||||
success!("Name: {}", yk.name());
|
success!("Name: {}", yk.name());
|
||||||
success!("Version: {}", yk.version());
|
success!("Version: {}", yk.version());
|
||||||
success!("Serial: {}", yk.serial().0);
|
success!("Serial: {}", yk.serial().0);
|
||||||
|
// success!("{:?}", yk.config());
|
||||||
|
if let Ok(pin_retries) = yk.get_pin_retries() {
|
||||||
|
success!("Pin retries: {}", pin_retries);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
|||||||
Reference in New Issue
Block a user