increase verbosity
This commit is contained in:
parent
1e5d0d4680
commit
fe98279228
@ -11,7 +11,7 @@ readme = "README.md"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
filesystem-hashing = "0.3.1"
|
filesystem-hashing = "0.3.4"
|
||||||
clap = { version = "4.5.4", features = ["derive"] }
|
clap = { version = "4.5.4", features = ["derive"] }
|
||||||
whoami = "1.5.1"
|
whoami = "1.5.1"
|
||||||
anyhow = "1.0.82"
|
anyhow = "1.0.82"
|
||||||
|
@ -11,6 +11,7 @@ pub struct CompareMode {
|
|||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
result_type: SnapshotChangeType,
|
result_type: SnapshotChangeType,
|
||||||
results: SnapshotCompareResult,
|
results: SnapshotCompareResult,
|
||||||
|
verbose: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompareMode {
|
impl CompareMode {
|
||||||
@ -21,8 +22,13 @@ impl CompareMode {
|
|||||||
count_only: Option<bool>,
|
count_only: Option<bool>,
|
||||||
verbose: Option<bool>,
|
verbose: Option<bool>,
|
||||||
) -> CompareMode {
|
) -> CompareMode {
|
||||||
let left = import_snapshot(left).unwrap_or_default();
|
let mut verbosity = false;
|
||||||
let right = import_snapshot(right).unwrap_or_default();
|
if let Some(_v) = verbose {
|
||||||
|
verbosity = true
|
||||||
|
}
|
||||||
|
|
||||||
|
let left = import_snapshot(left, verbosity).unwrap_or_default();
|
||||||
|
let right = import_snapshot(right, verbosity).unwrap_or_default();
|
||||||
|
|
||||||
CompareMode {
|
CompareMode {
|
||||||
left,
|
left,
|
||||||
@ -35,18 +41,19 @@ impl CompareMode {
|
|||||||
deleted: vec![],
|
deleted: vec![],
|
||||||
changed: vec![],
|
changed: vec![],
|
||||||
},
|
},
|
||||||
|
verbose: verbosity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompareMode {
|
impl CompareMode {
|
||||||
pub(crate) fn run(&mut self) -> Result<(), Error> {
|
pub(crate) fn run(&mut self, verbose: Option<bool>) -> Result<(), Error> {
|
||||||
let selector = match &self.selection {
|
let selector = match &self.selection {
|
||||||
None => "none",
|
None => "none",
|
||||||
Some(r) => r.as_str(),
|
Some(r) => r.as_str(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let results = match compare_snapshots(self.left.clone(), self.right.clone()) {
|
let results = match compare_snapshots(self.left.clone(), self.right.clone(), self.verbose) {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => panic!("Error Comparing Snapshot"),
|
None => panic!("Error Comparing Snapshot"),
|
||||||
};
|
};
|
||||||
|
@ -9,10 +9,21 @@ pub struct CreateMode {
|
|||||||
snapshot_path: String,
|
snapshot_path: String,
|
||||||
root_path: String,
|
root_path: String,
|
||||||
snapshot: Snapshot,
|
snapshot: Snapshot,
|
||||||
|
verbose: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CreateMode {
|
impl CreateMode {
|
||||||
pub fn new(snapshot_path: String, root_path: String, verbose: Option<bool>) -> CreateMode {
|
pub fn new(snapshot_path: String, root_path: String, verbose: Option<bool>) -> CreateMode {
|
||||||
|
let mut verbosity = false;
|
||||||
|
match verbose {
|
||||||
|
Some(_v) => {
|
||||||
|
verbosity = true
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
verbosity = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if snapshot_path.replace("./", "").is_empty() {
|
if snapshot_path.replace("./", "").is_empty() {
|
||||||
println!("Specify output file name");
|
println!("Specify output file name");
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -31,12 +42,22 @@ impl CreateMode {
|
|||||||
uuid: "".to_string(),
|
uuid: "".to_string(),
|
||||||
date_created: 0,
|
date_created: 0,
|
||||||
},
|
},
|
||||||
|
verbose: verbosity,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CreateMode {
|
impl CreateMode {
|
||||||
pub fn run(&mut self) -> Result<(), Error> {
|
pub fn run(&mut self, verbose: Option<bool>) -> Result<(), Error> {
|
||||||
|
let mut verbosity = false;
|
||||||
|
match verbose {
|
||||||
|
Some(v) => {
|
||||||
|
verbosity = v
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
verbosity = true
|
||||||
|
}
|
||||||
|
}
|
||||||
let snapshot = create_snapshot(
|
let snapshot = create_snapshot(
|
||||||
self.root_path.as_str(),
|
self.root_path.as_str(),
|
||||||
BLAKE3,
|
BLAKE3,
|
||||||
@ -46,12 +67,13 @@ impl CreateMode {
|
|||||||
"/tmp".to_string(),
|
"/tmp".to_string(),
|
||||||
"/sys".to_string(),
|
"/sys".to_string(),
|
||||||
],
|
],
|
||||||
|
verbosity
|
||||||
)?;
|
)?;
|
||||||
self.snapshot = snapshot.clone();
|
self.snapshot = snapshot.clone();
|
||||||
if let Ok(e) = snapshot.file_hashes.lock() {
|
if let Ok(e) = snapshot.file_hashes.lock() {
|
||||||
println!("Total FileHash Entries {}", e.len());
|
println!("Total FileHash Entries {}", e.len());
|
||||||
}
|
}
|
||||||
export_snapshot(self.snapshot.clone(), self.snapshot_path.clone(), true)?;
|
export_snapshot(self.snapshot.clone(), self.snapshot_path.clone(), true, self.verbose)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@ fn main() {
|
|||||||
} => {
|
} => {
|
||||||
let mut create = CreateMode::new(output_path, root_dir, verbose);
|
let mut create = CreateMode::new(output_path, root_dir, verbose);
|
||||||
println!("Creating snapshot..");
|
println!("Creating snapshot..");
|
||||||
create.run()
|
println!("{:?}", verbose);
|
||||||
|
create.run(verbose)
|
||||||
}
|
}
|
||||||
Commands::Compare {
|
Commands::Compare {
|
||||||
left,
|
left,
|
||||||
@ -32,7 +33,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut compare = CompareMode::new(left, right, selection, count_only, verbose);
|
let mut compare = CompareMode::new(left, right, selection, count_only, verbose);
|
||||||
compare.run()
|
compare.run(verbose)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user