Skip to content

Commit

Permalink
Merge pull request #1031 from breez/json-command-output
Browse files Browse the repository at this point in the history
Use json as command output
  • Loading branch information
roeierez authored Jul 6, 2024
2 parents 8c27e8b + 45100b5 commit b7c4f1a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
17 changes: 9 additions & 8 deletions libs/sdk-core/src/greenlight/node_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,8 @@ impl NodeAPI for Greenlight {
.list_peers(cln::ListpeersRequest::default())
.await?
.into_inner();
Ok(format!("{resp:?}"))

Ok(serde_json::to_string_pretty(&resp)?)
}
NodeCommand::ListPeerChannels => {
let resp = self
Expand All @@ -1473,7 +1474,7 @@ impl NodeAPI for Greenlight {
.list_peer_channels(cln::ListpeerchannelsRequest::default())
.await?
.into_inner();
Ok(format!("{resp:?}"))
Ok(serde_json::to_string_pretty(&resp)?)
}
NodeCommand::ListFunds => {
let resp = self
Expand All @@ -1482,7 +1483,7 @@ impl NodeAPI for Greenlight {
.list_funds(cln::ListfundsRequest::default())
.await?
.into_inner();
Ok(format!("{resp:?}"))
Ok(serde_json::to_string_pretty(&resp)?)
}
NodeCommand::ListPayments => {
let resp = self
Expand All @@ -1491,7 +1492,7 @@ impl NodeAPI for Greenlight {
.list_pays(cln::ListpaysRequest::default())
.await?
.into_inner();
Ok(format!("{resp:?}"))
Ok(serde_json::to_string_pretty(&resp)?)
}
NodeCommand::ListInvoices => {
let resp = self
Expand All @@ -1500,7 +1501,7 @@ impl NodeAPI for Greenlight {
.list_invoices(cln::ListinvoicesRequest::default())
.await?
.into_inner();
Ok(format!("{resp:?}"))
Ok(serde_json::to_string_pretty(&resp)?)
}
NodeCommand::CloseAllChannels => {
let peers_res = self
Expand All @@ -1522,11 +1523,11 @@ impl NodeAPI for Greenlight {
.getinfo(cln::GetinfoRequest::default())
.await?
.into_inner();
Ok(format!("{resp:?}"))
Ok(serde_json::to_string_pretty(&resp)?)
}
NodeCommand::GenerateDiagnosticData => {
let resp = self.generate_diagnostic_data().await?;
Ok(format!("{resp:?}"))
Ok(serde_json::to_string_pretty(&resp)?)
}
NodeCommand::Stop => {
let resp = self
Expand All @@ -1535,7 +1536,7 @@ impl NodeAPI for Greenlight {
.stop(cln::StopRequest::default())
.await?
.into_inner();
Ok(format!("{resp:?}"))
Ok(serde_json::to_string_pretty(&resp)?)
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions tools/sdk-cli/src/command_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,7 @@ pub(crate) async fn handle_command(
.await?;
Ok("Report sent".into())
}
Commands::ExecuteDevCommand { command } => {
serde_json::to_string_pretty(&sdk()?.execute_dev_command(command).await?)
.map_err(|e| e.into())
}
Commands::ExecuteDevCommand { command } => Ok(sdk()?.execute_dev_command(command).await?),
Commands::GenerateDiagnosticData {} => Ok(sdk()?.generate_diagnostic_data().await?),
Commands::BuyBitcoin { provider } => {
let res = sdk()?
Expand Down

0 comments on commit b7c4f1a

Please sign in to comment.