From d1b008d14a07e32431726418d6767a7b0c784f8c Mon Sep 17 00:00:00 2001 From: Juan Diego Carballo Date: Tue, 8 Oct 2024 03:31:57 -0600 Subject: [PATCH] feat: add script to convert the entire response to JSON --- cmd/soroban-cli/src/commands/events.rs | 30 +++++++++----------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/cmd/soroban-cli/src/commands/events.rs b/cmd/soroban-cli/src/commands/events.rs index 5e2bda66f..945def457 100644 --- a/cmd/soroban-cli/src/commands/events.rs +++ b/cmd/soroban-cli/src/commands/events.rs @@ -156,26 +156,16 @@ impl Cmd { let response = self.run_against_rpc_server(None, None).await?; - for event in &response.events { - match self.output { - // Should we pretty-print the JSON like we're doing here or just - // dump an event in raw JSON on each line? The latter is easier - // to consume programmatically. - OutputFormat::Json => { - println!( - "{}", - serde_json::to_string_pretty(&event).map_err(|e| { - Error::InvalidJson { - debug: format!("{event:#?}"), - error: e, - } - })?, - ); - } - OutputFormat::Plain => println!("{event}"), - OutputFormat::Pretty => event.pretty_print()?, - } - } + // Convert the entire response to JSON + let json_response = + serde_json::to_string_pretty(&response).map_err(|e| Error::InvalidJson { + debug: format!("{response:#?}"), + error: e, + })?; + + // Print the JSON response + println!("{}", json_response); + Ok(()) }