From 2c09d79db9339670eee84d1896899dca382399a9 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 11 Jan 2021 00:20:58 +0000 Subject: [PATCH] otterlib: wip preview Signed-off-by: Ian Jackson --- src/bin/otterlib.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/bin/otterlib.rs b/src/bin/otterlib.rs index b419497d..1fd05215 100644 --- a/src/bin/otterlib.rs +++ b/src/bin/otterlib.rs @@ -24,6 +24,20 @@ pub struct Opts { #[derive(StructOpt,Debug,Clone,Copy)] pub enum OutputKind { List, + Preview, +} + +pub type ItemForOutput = (String, ItemEnquiryData); + +#[throws(AE)] +fn preview(items: Vec) { + let pieces = items.into_iter().map(|it| { + let spec = ItemSpec { lib: it.0, item: it.1.itemname }; + spec.clone().load() + .with_context(|| format!("{:?}", &spec)) + }) + .collect::>,AE>>()?; + dbg!(&pieces); } #[throws(anyhow::Error)] @@ -40,7 +54,7 @@ fn main() { let libs = Config1::PathGlob(opts.libs.clone()); load(&vec![libs.clone()])?; - let mut items : Vec<(String, ItemEnquiryData)> = + let mut items : Vec = libs_list() .into_iter() .map(|lib| { @@ -60,6 +74,9 @@ fn main() { OutputKind::List => for item in &items { println!("{:<10} {}", &item.0, item.1.line_for_list()); } + OutputKind::Preview => { + preview(items)? + } } } -- 2.30.2