feat: support --json
This commit is contained in:
@@ -21,12 +21,15 @@ impl Command for CommandImpl {
|
||||
}
|
||||
|
||||
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
||||
let json_output = sub_arg_matches.is_present("json");
|
||||
if json_output {
|
||||
rust_util::util_msg::set_logger_std_out(false);
|
||||
}
|
||||
let app_id = sub_arg_matches.value_of("app-id").unwrap();
|
||||
let timeout_ms = match sub_arg_matches.value_of("timeout").unwrap().parse::<u32>() {
|
||||
Ok(t) => (t * 1000) as u64,
|
||||
Err(e) => return simple_error!("Timeout should be a number: {}", e),
|
||||
};
|
||||
let json_output = sub_arg_matches.is_present("json");
|
||||
|
||||
let u2fv2_challenge = U2fV2Challenge::new_random(app_id);
|
||||
let u2fv2_challenge_str = u2fv2_challenge.to_json();
|
||||
@@ -65,7 +68,7 @@ impl Command for CommandImpl {
|
||||
match u2f_registration_data {
|
||||
Ok(data) => {
|
||||
if json_output {
|
||||
success!("{}", serde_json::to_string_pretty(&data).unwrap());
|
||||
println!("{}", serde_json::to_string_pretty(&data).unwrap());
|
||||
} else {
|
||||
success!("Device info: {}", data.device_info);
|
||||
if let Some(cert) = data.attestation_cert_pem {
|
||||
|
||||
Reference in New Issue
Block a user