Skip to content
Snippets Groups Projects
Commit dfcc91f2 authored by fred's avatar fred
Browse files

ok

parent 1f167716
No related branches found
No related tags found
1 merge request!49Draft: Nostr
Pipeline #40722 passed
This commit is part of merge request !49. Comments created here will be created in the context of that merge request.
......@@ -191,6 +191,42 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
let i_latest_h = convert_hash_bytea(i_latest_block.hash);
let i_latest_n = i_latest_block.height;
match data.args.output_format {
OutputFormat::Json => {
let output = serde_json::json!({
"duniter": {
"url": d_url,
"genesis_hash": d_gen_hash,
"finalized_block": {
"number": d_finalized_n,
"hash": d_finalized_h.to_string()
},
"latest_block": {
"number": d_latest_n,
"hash": d_latest_h.to_string()
}
},
"indexer": {
"url": i_url,
"genesis_hash": i_gen_hash,
"finalized_block": {
"number": i_finalized_n,
"hash": i_finalized_h.map(|h| h.to_string())
},
"latest_block": {
"number": i_latest_n,
"hash": i_latest_h.to_string()
}
},
"status": {
"genesis_hash_match": d_gen_hash == i_gen_hash,
"finalized_block_match": i_finalized_h.map_or(false, |h| h == d_finalized_h),
"latest_block_match": i_latest_n == d_latest_n as i64 && i_latest_h == d_latest_h
}
});
println!("{}", serde_json::to_string_pretty(&output).unwrap());
},
OutputFormat::Human => {
fn color(x: bool) -> Color {
match x {
true => Color::Green,
......@@ -245,6 +281,8 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
println!("{table}");
}
}
}
};
Ok(())
......
......@@ -116,6 +116,8 @@ pub enum GcliError {
/// error coming from io
#[allow(dead_code)]
IoError(std::io::Error),
/// error coming from config
Config(String),
}
impl std::fmt::Display for GcliError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment