fix: handle multiple file arguments for show and edit
This commit is contained in:
+27
-9
@@ -1,4 +1,5 @@
|
||||
use clap::{Parser, Subcommand};
|
||||
//use ini::Ini;
|
||||
use lofty::file::TaggedFileExt;
|
||||
use lofty::probe::Probe;
|
||||
use std::ffi::OsStr;
|
||||
@@ -21,20 +22,35 @@ struct Args {
|
||||
#[derive(Subcommand)]
|
||||
enum Commands {
|
||||
Import {
|
||||
#[arg(num_args = 1..)]
|
||||
files: Vec<PathBuf>,
|
||||
#[arg(short, long, default_value_t = false)]
|
||||
copy: bool,
|
||||
},
|
||||
Show {
|
||||
file: PathBuf,
|
||||
files: Vec<PathBuf>,
|
||||
},
|
||||
Edit {
|
||||
files: PathBuf,
|
||||
files: Vec<PathBuf>,
|
||||
},
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
//let mut conf = Ini::new();
|
||||
//conf.with_section(Some("General"))
|
||||
// .set("target_directory", "");
|
||||
////conf.write_to_file("conf.ini").unwrap();
|
||||
//
|
||||
//let conf = Ini::load_from_file("conf.ini").unwrap();
|
||||
//
|
||||
//let section = conf.section(Some("General")).unwrap();
|
||||
//println!("target_dir={:?}", section.get("target_directory"));
|
||||
//
|
||||
//for (_sec, prop) in &conf {
|
||||
// for (key, value) in prop.iter() {
|
||||
// println!("{:?}:{:?}", key, value);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
let args = Args::parse();
|
||||
let extra_files = ["jpg", "png", "pdf", "log", "cue", "mp4", "lrc", "txt"].map(str::to_string);
|
||||
|
||||
@@ -70,17 +86,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
}
|
||||
|
||||
Commands::Show { file } => {
|
||||
println!("Show file: {:?}", file);
|
||||
let tag = get_metadata(file);
|
||||
Commands::Show { files } => {
|
||||
for file in files {
|
||||
println!("Show file: {:?}", file);
|
||||
let tag = get_metadata(file);
|
||||
|
||||
for item in tag.items() {
|
||||
println!("{:?}", item)
|
||||
for item in tag.items() {
|
||||
println!("{:?}", item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Commands::Edit { files } => {
|
||||
edit(files.to_path_buf(), extra_files)?;
|
||||
edit(files.to_vec(), extra_files)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user