mithril_client_cli/utils/
mod.rs1mod archive_unpacker;
5mod cardano_db;
6mod cardano_db_download_checker;
7mod expander;
8mod feedback_receiver;
9mod forced_era_fetcher;
10mod fs;
11mod github_release_retriever;
12mod http_downloader;
13mod multi_download_progress_reporter;
14mod progress_reporter;
15
16pub use archive_unpacker::*;
17pub use cardano_db::*;
18pub use cardano_db_download_checker::*;
19pub use expander::*;
20pub use feedback_receiver::*;
21pub use forced_era_fetcher::*;
22pub use fs::*;
23pub use github_release_retriever::*;
24pub use http_downloader::*;
25pub use multi_download_progress_reporter::*;
26pub use progress_reporter::*;
27
28use anyhow::Context;
29use mithril_client::MithrilResult;
30use std::path::Path;
31
32pub(crate) const JSON_CAUTION_KEY: &str = "caution";
34
35pub(crate) fn print_simple_warning(message: &str, is_json_output_enabled: bool) {
41 if is_json_output_enabled {
42 eprintln!(r#"{{"{JSON_CAUTION_KEY}":"{message}"}}"#);
43 } else {
44 eprintln!("Warning: {message}");
45 }
46}
47
48pub(crate) fn path_to_string(path: &Path) -> MithrilResult<String> {
50 let path = path
51 .to_str()
52 .with_context(|| {
53 format!(
54 "Path '{}' contains invalid UTF-8 characters.",
55 path.display()
56 )
57 })?
58 .to_string();
59
60 Ok(path)
61}