Skip to content

Commit ae513c3

Browse files
committed
WIP: start to display error lists in CLI
1 parent 3cc9a36 commit ae513c3

File tree

1 file changed

+26
-1
lines changed
  • mithril-client-cli/src/commands/cardano_db

1 file changed

+26
-1
lines changed

mithril-client-cli/src/commands/cardano_db/verify.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
use anyhow::{Context, anyhow};
88
use chrono::Utc;
99
use clap::Parser;
10-
use mithril_client::{ComputeCardanoDatabaseMessageError, MithrilResult};
10+
use mithril_client::{ComputeCardanoDatabaseMessageError, ImmutableFilesLists, MithrilResult};
1111

1212
use crate::{
1313
CommandContext,
@@ -128,6 +128,10 @@ impl CardanoDbVerifyCommand {
128128
Err(e) => match e.downcast_ref::<ComputeCardanoDatabaseMessageError>() {
129129
Some(ComputeCardanoDatabaseMessageError::ImmutableFilesVerification(lists)) => {
130130
// let missing_files = lists.missing;
131+
Self::print_immutables_verification_error(
132+
lists,
133+
context.is_json_output_enabled(),
134+
);
131135
Ok(())
132136
}
133137
_ => Err(anyhow!(e)),
@@ -176,6 +180,27 @@ impl CardanoDbVerifyCommand {
176180
}
177181
Ok(())
178182
}
183+
184+
fn print_immutables_verification_error(lists: &ImmutableFilesLists, json_output: bool) {
185+
if json_output {
186+
let json = serde_json::json!({
187+
"timestamp": Utc::now().to_rfc3339(),
188+
"immutables_dir": lists.immutables_dir,
189+
"missing_files": lists.missing,
190+
"tampered_files": lists.tampered,
191+
});
192+
println!("{json}");
193+
} else {
194+
println!(
195+
r###"computing cardano database message from immutables files has failed:
196+
- missing files: {}
197+
- tampered files: {}
198+
"###,
199+
lists.missing.len(),
200+
lists.tampered.len()
201+
);
202+
}
203+
}
179204
}
180205

181206
impl ConfigSource for CardanoDbVerifyCommand {

0 commit comments

Comments
 (0)