diff --git a/src/cmd_pgpcardlist.rs b/src/cmd_pgpcardlist.rs index 2f97524..1969e34 100644 --- a/src/cmd_pgpcardlist.rs +++ b/src/cmd_pgpcardlist.rs @@ -19,11 +19,12 @@ impl Command for CommandImpl { let json_output = sub_arg_matches.is_present("json"); 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: {}"); information!("Found {} card(s)", cards.len()); for (i, mut card) in cards.into_iter().enumerate() { + let mut json = BTreeMap::new(); let mut pgp = OpenPgp::new(&mut card); let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}"); if let Ok(application_related_data) = trans.application_related_data() { @@ -119,10 +120,11 @@ impl Command for CommandImpl { } } } + jsons.push(json); } if json_output { - println!("{}", serde_json::to_string_pretty(&json).unwrap()); + println!("{}", serde_json::to_string_pretty(&jsons).unwrap()); } Ok(None) }