display error if directory not specified

This commit is contained in:
Paul Campbell 2023-11-29 15:15:00 +00:00
parent e22c29ce64
commit 4ff5199285

View file

@ -6,7 +6,13 @@ use std::{
};
fn main() {
let directory = args().nth(1).unwrap();
match args().nth(1) {
Some(dir) => rename_files_in_directory(dir),
None => println!("Please provide a directory"),
}
}
fn rename_files_in_directory(directory: String) {
println!("Renaming files in {}", directory);
match rename_files(&directory, &directory) {
Ok(count) => println!("Renamed {} files", count),