use std::path::PathBuf;
use crate::core::metadata::read_metadata;
use crate::error::Result;
#[derive(clap::Args)]
pub struct Args {
#[arg(short, long)]
pub json: bool,
pub file: Vec<PathBuf>,
}
pub fn run(args: &Args) -> Result<()> {
let multi = args.file.len() > 1;
for file in &args.file {
let result = read_metadata(file);
let meta = match result {
Ok(m) => m,
Err(e) => {
eprintln!("{}: {e:#}", file.display());
continue;
}
};
if args.json {
println!("{}", serde_json::to_string(&meta)?);
} else {
if multi {
println!("{}:", file.display());
}
println!("{meta}");
if multi {
println!();
}
}
}
Ok(())
}