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
...@@ -191,6 +191,42 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE ...@@ -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_h = convert_hash_bytea(i_latest_block.hash);
let i_latest_n = i_latest_block.height; 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 { fn color(x: bool) -> Color {
match x { match x {
true => Color::Green, true => Color::Green,
...@@ -245,6 +281,8 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE ...@@ -245,6 +281,8 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
println!("{table}"); println!("{table}");
} }
}
}
}; };
Ok(()) Ok(())
......
...@@ -116,6 +116,8 @@ pub enum GcliError { ...@@ -116,6 +116,8 @@ pub enum GcliError {
/// error coming from io /// error coming from io
#[allow(dead_code)] #[allow(dead_code)]
IoError(std::io::Error), IoError(std::io::Error),
/// error coming from config
Config(String),
} }
impl std::fmt::Display for GcliError { impl std::fmt::Display for GcliError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 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