Skip to main content

idb/cli/
mod.rs

1pub mod app;
2pub mod checksum;
3pub mod corrupt;
4pub mod dump;
5pub mod find;
6pub mod info;
7pub mod log;
8pub mod pages;
9pub mod parse;
10pub mod sdi;
11pub mod tsid;
12
13/// Write a line to the given writer, converting io::Error to IdbError.
14macro_rules! wprintln {
15    ($w:expr) => {
16        writeln!($w).map_err(|e| $crate::IdbError::Io(e.to_string()))
17    };
18    ($w:expr, $($arg:tt)*) => {
19        writeln!($w, $($arg)*).map_err(|e| $crate::IdbError::Io(e.to_string()))
20    };
21}
22
23/// Write (without newline) to the given writer, converting io::Error to IdbError.
24macro_rules! wprint {
25    ($w:expr, $($arg:tt)*) => {
26        write!($w, $($arg)*).map_err(|e| $crate::IdbError::Io(e.to_string()))
27    };
28}
29
30pub(crate) use wprintln;
31pub(crate) use wprint;
32
33use indicatif::{ProgressBar, ProgressStyle};
34
35/// Create a styled progress bar for iterating over pages or files.
36pub(crate) fn create_progress_bar(count: u64, unit: &str) -> ProgressBar {
37    let pb = ProgressBar::new(count);
38    pb.set_style(
39        ProgressStyle::default_bar()
40            .template(&format!(
41                "{{spinner:.green}} [{{bar:40.cyan/blue}}] {{pos}}/{{len}} {} ({{eta}})",
42                unit
43            ))
44            .unwrap()
45            .progress_chars("#>-"),
46    );
47    pb
48}