use anyhow::Context;
use rayon::prelude::*;
use std::path::{Path, PathBuf};
use structopt::StructOpt;
use summain::ManifestEntry;
fn main() -> anyhow::Result<()> {
let mut opt = Opt::from_args();
opt.pathnames[..].sort();
let v: Vec<anyhow::Result<ManifestEntry>> =
opt.pathnames.par_iter().map(|p| manifest(&p)).collect();
for m in v {
let m = m?;
println!("{}", serde_yaml::to_string(&m)?);
}
Ok(())
}
#[derive(StructOpt, Debug)]
struct Opt {
#[structopt(parse(from_os_str))]
pathnames: Vec<PathBuf>,
}
fn manifest(path: &Path) -> anyhow::Result<ManifestEntry> {
ManifestEntry::new(path).with_context(|| format!("{}", path.display()))
}