From: Ian Jackson Date: Sun, 10 Jan 2021 16:39:25 +0000 (+0000) Subject: otterlib: list option X-Git-Tag: otter-0.3.0~110 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3d260fd535e223a887b21fa050a1329e1a076e5d;p=otter.git otterlib: list option Signed-off-by: Ian Jackson --- diff --git a/src/bin/otter.rs b/src/bin/otter.rs index 5ba2951b..3e958ab6 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -1108,7 +1108,7 @@ mod library_list { let items = chan.list_items(&args.pat)?; for it in &items { - println!("{:20} {}", it.itemname, it.f0desc.0); + println!("{}", it.line_for_list()); } Ok(()) diff --git a/src/bin/otterlib.rs b/src/bin/otterlib.rs index 277fe4b6..c2fc51ed 100644 --- a/src/bin/otterlib.rs +++ b/src/bin/otterlib.rs @@ -16,6 +16,14 @@ pub struct Opts { #[structopt(long="--items", default_value="*")] items: String, + + #[structopt(flatten)] + output: OutputKind, +} + +#[derive(StructOpt,Debug,Clone,Copy)] +pub enum OutputKind { + List, } #[throws(anyhow::Error)] @@ -36,9 +44,8 @@ fn main() { for lib in libnames { let contents = libs_lookup(&lib)?; let items = contents.list_glob(&opts.items)?; - dbg!(&items); for item in items { - dbg!(&item); + println!("{}", item.line_for_list()); } } } diff --git a/src/shapelib.rs b/src/shapelib.rs index f93b1cda..c1620a43 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -174,6 +174,12 @@ pub struct ItemEnquiryData { pub f0bbox: [Pos; 2], } +impl ItemEnquiryData { + pub fn line_for_list(&self) -> String { + format!("{:20} {}", self.itemname, self.f0desc.0) + } +} + #[typetag::serde(name="Lib")] impl Outline for Item { delegate! { to self.outline { fn surround_path(&self, pri: &PieceRenderInstructions) -> Result;