feat: pgp-card-list
This commit is contained in:
@@ -19,11 +19,12 @@ 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 mut json = BTreeMap::new();
|
let mut jsons = vec![];
|
||||||
let cards = opt_result!(PcscBackend::cards(None), "Failed to list OpenPGP cards: {}");
|
let cards = opt_result!(PcscBackend::cards(None), "Failed to list OpenPGP cards: {}");
|
||||||
|
|
||||||
information!("Found {} card(s)", cards.len());
|
information!("Found {} card(s)", cards.len());
|
||||||
for (i, mut card) in cards.into_iter().enumerate() {
|
for (i, mut card) in cards.into_iter().enumerate() {
|
||||||
|
let mut json = BTreeMap::new();
|
||||||
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 let Ok(application_related_data) = trans.application_related_data() {
|
if let Ok(application_related_data) = trans.application_related_data() {
|
||||||
@@ -119,10 +120,11 @@ impl Command for CommandImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
jsons.push(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
if json_output {
|
if json_output {
|
||||||
println!("{}", serde_json::to_string_pretty(&json).unwrap());
|
println!("{}", serde_json::to_string_pretty(&jsons).unwrap());
|
||||||
}
|
}
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user