diff --git a/src/enclave_proc_comm.rs b/src/enclave_proc_comm.rs index 7fd12e7c..e8c7e797 100644 --- a/src/enclave_proc_comm.rs +++ b/src/enclave_proc_comm.rs @@ -303,6 +303,7 @@ pub fn enclave_process_handle_all_replies( prev_failed_conns: usize, print_as_vec: bool, allowed_return_codes: Vec, + pretty_print: bool, ) -> NitroCliResult> where T: Clone + DeserializeOwned + Serialize, @@ -318,18 +319,28 @@ where // Output the received objects either individually or as an array. if print_as_vec { let obj_vec: Vec = objects.iter().map(|v| v.0.clone()).collect(); + let json_result = if pretty_print { + serde_json::to_string_pretty(&obj_vec) + } else { + serde_json::to_string(&obj_vec) + }; println!( "{}", - serde_json::to_string_pretty(&obj_vec).map_err(|e| new_nitro_cli_failure!( + json_result.map_err(|e| new_nitro_cli_failure!( &format!("Failed to print JSON vector: {:?}", e), NitroCliErrorEnum::SerdeError ))? ); } else { for object in objects.iter().map(|v| v.0.clone()) { + let json_result = if pretty_print { + serde_json::to_string_pretty(&object) + } else { + serde_json::to_string(&object) + }; println!( "{}", - serde_json::to_string_pretty(&object).map_err(|e| new_nitro_cli_failure!( + json_result.map_err(|e| new_nitro_cli_failure!( &format!("Failed to print JSON object: {:?}", e), NitroCliErrorEnum::SerdeError ))? diff --git a/src/lib.rs b/src/lib.rs index 169e64b0..29e9dcbd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -440,6 +440,7 @@ pub fn terminate_all_enclaves() -> NitroCliResult<()> { failed_connections.len() + err_socket_files, false, vec![0, libc::EACCES], + true, ) .map_err(|e| e.add_subaction("Failed to handle all enclave processes replies".to_string())) .map(|_| ()) diff --git a/src/main.rs b/src/main.rs index 3c46d6b4..4ab65b28 100644 --- a/src/main.rs +++ b/src/main.rs @@ -110,6 +110,7 @@ fn main() { 0, false, vec![0], + true, ) .map_err(|e| { e.add_subaction("Failed to handle all enclave process replies".to_string()) @@ -177,6 +178,7 @@ fn main() { 0, false, vec![0], + true, ) .map_err(|e| { e.add_subaction("Failed to handle all enclave process replies".to_string()) @@ -206,6 +208,7 @@ fn main() { comm_errors, true, vec![0], + true, ) .map_err(|e| { e.add_subaction("Failed to handle all enclave process replies".to_string())