Skip to content

Commit 147a73d

Browse files
committed
WIP: start to display error lists in CLI
1 parent 0a860b6 commit 147a73d

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,
@@ -129,6 +129,10 @@ impl CardanoDbVerifyCommand {
129129
Err(e) => match e.downcast_ref::<ComputeCardanoDatabaseMessageError>() {
130130
Some(ComputeCardanoDatabaseMessageError::ImmutableFilesVerification(lists)) => {
131131
// let missing_files = lists.missing;
132+
Self::print_immutables_verification_error(
133+
lists,
134+
context.is_json_output_enabled(),
135+
);
132136
Ok(())
133137
}
134138
_ => Err(anyhow!(e)),
@@ -177,6 +181,27 @@ impl CardanoDbVerifyCommand {
177181
}
178182
Ok(())
179183
}
184+
185+
fn print_immutables_verification_error(lists: &ImmutableFilesLists, json_output: bool) {
186+
if json_output {
187+
let json = serde_json::json!({
188+
"timestamp": Utc::now().to_rfc3339(),
189+
"immutables_dir": lists.immutables_dir,
190+
"missing_files": lists.missing,
191+
"tampered_files": lists.tampered,
192+
});
193+
println!("{json}");
194+
} else {
195+
println!(
196+
r###"computing cardano database message from immutables files has failed:
197+
- missing files: {}
198+
- tampered files: {}
199+
"###,
200+
lists.missing.len(),
201+
lists.tampered.len()
202+
);
203+
}
204+
}
180205
}
181206

182207
impl ConfigSource for CardanoDbVerifyCommand {

0 commit comments

Comments
 (0)