diff --git a/src/main.rs b/src/main.rs index 1d5c7a8..66e7678 100755 --- a/src/main.rs +++ b/src/main.rs @@ -17,8 +17,14 @@ struct Args { #[derive(Subcommand)] enum Commands { - Import { file: PathBuf }, - Show { file: PathBuf }, + Import { + file: PathBuf, + #[arg(short, long, default_value_t = false)] + copy: bool, + }, + Show { + file: PathBuf, + }, } fn main() -> Result<(), Box> { @@ -26,7 +32,7 @@ fn main() -> Result<(), Box> { let extra_files = ["jpg", "png", "pdf", "log", "cue", "mp4", "lrc", "txt"].map(str::to_string); match &args.command { - Commands::Import { file } => { + Commands::Import { file, copy } => { if file.is_dir() { println!("Importing folder: {:?}", file); for music_file in read_dir(file)? { @@ -39,12 +45,12 @@ fn main() -> Result<(), Box> { continue; } let tag = get_metadata(&path); - let _ = move_files(path, tag.clone(), extra_files.clone()); + let _ = move_files(path, tag.clone(), extra_files.clone(), *copy); } } else { println!("Importing file: {:?}", file); let tag = get_metadata(file); - let _ = move_files(file.clone(), tag.clone(), extra_files); + let _ = move_files(file.clone(), tag.clone(), extra_files, *copy); } } Commands::Show { file } => { diff --git a/src/move_files.rs b/src/move_files.rs index 29b91cb..1c4586b 100644 --- a/src/move_files.rs +++ b/src/move_files.rs @@ -9,6 +9,7 @@ pub fn move_files( file_path: PathBuf, tag: Tag, extra_files: [String; 8], + should_copy: bool, ) -> Result<(), Box> { let target_dir = PathBuf::from("/home/user/Desktop/coding/keks-sort"); @@ -33,7 +34,6 @@ pub fn move_files( let _ = create_dir_all(dir_to_create); let target = target_dir.join(artist_dir).join(album_dir.as_ref()); - let should_copy = true; if should_copy { copy(&file_path, target.join(file_path.file_name().unwrap()))?; } else {