added delete options

This commit is contained in:
sreedev
2023-01-10 20:23:53 -05:00
parent 3fd4869869
commit 471e60fa6c
2 changed files with 11 additions and 2 deletions

View File

@@ -1,7 +1,14 @@
use crate::database::File;
use anyhow::Result;
use colored::Colorize;
pub fn delete_files(files: Vec<File>) -> Result<()> {
println!("{:?} DELETED", files);
files.into_iter().for_each(|file| {
match std::fs::remove_file(file.path.clone()) {
Ok(_) => println!("{}: {}", "DELETED".green(), file.path),
Err(e) => println!("{}: {}", "FAILED".red(), file.path)
}
});
Ok(())
}

View File

@@ -97,12 +97,14 @@ fn process_group_action(duplicates: &Vec<File>, dup_index: usize, dup_size: usiz
.into_iter()
.any(|index| index > (duplicates.len() - 1))
{
println!("Err: File Index Out of Bounds!");
println!("{}", "Err: File Index Out of Bounds!".red());
return process_group_action(duplicates, dup_index, dup_size, table);
}
print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
if parsed_file_indices.is_empty() { return }
let files_to_delete = parsed_file_indices
.into_iter()
.map(|index| duplicates[index].clone());