chiark / gitweb /
otterlib: list option
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 Jan 2021 16:39:25 +0000 (16:39 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 Jan 2021 23:19:44 +0000 (23:19 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/otter.rs
src/bin/otterlib.rs
src/shapelib.rs

index 5ba2951b2f8579fd01dbcec9bb48fb859a938196..3e958ab6e1fed0d3b23b1288c33d4489efdec6a6 100644 (file)
@@ -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(())
index 277fe4b671d762a6d88a2759e60bd31bbcea8482..c2fc51ed1a770b7c6778e4974dd935236d5e156e 100644 (file)
@@ -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());
     }
   }
 }
index f93b1cdaadaa42b4fccea5f4fe072cb2d4fbdd51..c1620a43da67fa9f74d519b0a148c47d85216e6f 100644 (file)
@@ -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<Html, IE>;