Added support for dry running

This commit is contained in:
Sayantan Santra 2022-12-08 00:29:11 -06:00
parent e529ab2100
commit 89135740a8

View file

@ -56,7 +56,19 @@ fn main() {
api_key: api_key,
language: "en",
};
let mut dry_run = false;
if filenames.contains(&"--dry-run".to_string()) {
println!("Doing a dry run.");
dry_run = true;
}
for filename in filenames {
if filename == "--dry-run".to_string() {
continue;
}
let metadata = Metadata::from(filename.as_str()).unwrap();
let results = tmdb
.search()
@ -112,10 +124,13 @@ fn main() {
println!("{} already has correct name.", filename);
} else {
println!("{} -> {}", filename, new_name);
if dry_run == false {
println!("Doing the actual rename.");
fs::rename(filename, new_name).expect("Unable to rename file.");
}
}
}
}
fn display(movie: &MovieEntry) -> String {
let mut buffer = String::new();