From 1e5d0d468078b8ec2606d0b007e58e9f070b0473 Mon Sep 17 00:00:00 2001 From: foxx Date: Sun, 21 Apr 2024 13:42:54 -0400 Subject: [PATCH] increase verbosity --- src/comparemode.rs | 7 ++++--- src/createmode.rs | 18 +++++++++++------- src/main.rs | 7 ++++--- src/options.rs | 14 ++++++++++---- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/comparemode.rs b/src/comparemode.rs index 46ccab4..98f4b81 100644 --- a/src/comparemode.rs +++ b/src/comparemode.rs @@ -19,6 +19,7 @@ impl CompareMode { right: String, selection: Option, count_only: Option, + verbose: Option, ) -> CompareMode { let left = import_snapshot(left).unwrap_or_default(); let right = import_snapshot(right).unwrap_or_default(); @@ -112,12 +113,12 @@ mod tests { let right_dir = format!("/home/{}/Documents/", user); println!("{right}"); - let mut n1 = CreateMode::new(left.clone(), "/etc".to_string()); + let mut n1 = CreateMode::new(left.clone(), "/etc".to_string(), ); let _ = n1.run(); - let mut n2 = CreateMode::new(right.clone(), "/etc".to_string()); + let mut n2 = CreateMode::new(right.clone(), "/etc".to_string(), ); let _ = n2.run(); - let cm = CompareMode::new(left, right, None, None); + let cm = CompareMode::new(left, right, None, None, ); // println!("{:?}", cm); assert!(cm.left.file_hashes.lock().unwrap().len() > 0); diff --git a/src/createmode.rs b/src/createmode.rs index 287b51e..c653650 100644 --- a/src/createmode.rs +++ b/src/createmode.rs @@ -12,7 +12,7 @@ pub struct CreateMode { } impl CreateMode { - pub fn new(snapshot_path: String, root_path: String) -> CreateMode { + pub fn new(snapshot_path: String, root_path: String, verbose: Option) -> CreateMode { if snapshot_path.replace("./", "").is_empty() { println!("Specify output file name"); exit(0); @@ -37,12 +37,16 @@ impl CreateMode { impl CreateMode { pub fn run(&mut self) -> Result<(), Error> { - let snapshot = create_snapshot(self.root_path.as_str(), BLAKE3, vec![ - "/dev".to_string(), - "/proc".to_string(), - "/tmp".to_string(), - "/sys".to_string(), - ])?; + let snapshot = create_snapshot( + self.root_path.as_str(), + BLAKE3, + vec![ + "/dev".to_string(), + "/proc".to_string(), + "/tmp".to_string(), + "/sys".to_string(), + ], + )?; self.snapshot = snapshot.clone(); if let Ok(e) = snapshot.file_hashes.lock() { println!("Total FileHash Entries {}", e.len()); diff --git a/src/main.rs b/src/main.rs index f6eaee3..37749fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,9 +13,9 @@ fn main() { let _app = match options.command { Commands::Create { root_dir, - output_path, + output_path, verbose, } => { - let mut create = CreateMode::new(output_path, root_dir); + let mut create = CreateMode::new(output_path, root_dir, verbose); println!("Creating snapshot.."); create.run() } @@ -24,13 +24,14 @@ fn main() { right, selection, count_only, + verbose, } => { if let Some(count_only) = count_only { if !count_only { println!("Running snapshot comparison.."); } } - let mut compare = CompareMode::new(left, right, selection, count_only); + let mut compare = CompareMode::new(left, right, selection, count_only, verbose); compare.run() } }; diff --git a/src/options.rs b/src/options.rs index de4c065..3c8a41b 100644 --- a/src/options.rs +++ b/src/options.rs @@ -16,20 +16,26 @@ pub enum Commands { /// Snapshot output/save location #[arg(short, long)] output_path: String, + /// OPTIONAL: Increase verbosity + #[arg(short, default_value="false", num_args = 0..2)] + verbose: Option, }, /// Compare two snapshots Compare { - /// left side of diff + /// Left side of diff #[arg(short, long)] left: String, - /// right side of diff + /// Right side of diff #[arg(short, long)] right: String, - /// OPTIONAL: specify which change type specifically to return + /// OPTIONAL: Wpecify which change type specifically to return #[arg(short, long)] selection: Option, - /// OPTIONAL: when using selection specify to return count only or not + /// OPTIONAL: When using selection specify to return count only or not #[arg(short, default_value="false", num_args = 0..2)] count_only: Option, + /// OPTIONAL: Increase verbosity + #[arg(short, default_value="false", num_args = 0..2)] + verbose: Option, }, }