chiark / gitweb /
ItemEnquiryData: Put the lib name in it
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 May 2021 21:21:37 +0000 (22:21 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 May 2021 22:36:15 +0000 (23:36 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-otter.rs
src/bin/otterlib.rs
src/shapelib.rs

index ca7af1b87a7777dfa26571d2029d6479ffbad981..646ae347e64d7b71b02d76936fef825faa24e049 100644 (file)
@@ -546,7 +546,7 @@ impl Ctx {
       "library-list @table@ wikimedia chess-yellow-?"
     )?;
     let output: String = self.otter(&command)?.into();
-    assert!( Regex::new("(?m)^chess-yellow-K  *the yellow king$")?
+    assert!( Regex::new("(?m)^wikimedia  *chess-yellow-K  *the yellow king$")?
              .find(&output)
              .is_some(),
              "got: {}", &output);
index c790fedded98dfd8a9dd3e2e04e2be67320c9dc3..73f0bd1f2978ebaba8114639efbdea14957dde56 100644 (file)
@@ -62,7 +62,7 @@ pub enum OutputKind {
   Preview,
 }
 
-pub type ItemForOutput = (String, ItemEnquiryData);
+pub type ItemForOutput = ItemEnquiryData;
 
 pub const VIS: ShowUnocculted = ShowUnocculted::new_visible();
 
@@ -93,8 +93,8 @@ fn preview(items: Vec<ItemForOutput>) {
   }
 
   let mut pieces: Vec<Prep> = items.into_iter().map(|it| {
-    let spec = ItemSpec { lib: it.0, item: it.1.itemname.into() };
-    let sortkey = it.1.sortkey;
+    let spec = ItemSpec { lib: it.libname.into(), item: it.itemname.into() };
+    let sortkey = it.sortkey;
     (||{
       let (p, _occultable) = spec.clone()
         .find_load(&ig_dummy, SpecDepth::zero())
@@ -239,7 +239,7 @@ fn main() {
     for contents in all_registries.lib_name_lookup(&lib)? {
       for pat in opts.items.split(SPLIT) {
         for item in contents.list_glob(pat)? {
-          items.push((lib.clone(), item))
+          items.push(item)
         }
       }
     }
@@ -247,8 +247,8 @@ fn main() {
   items.sort();
 
   match opts.outkind {
-    OutputKind::List => for item in &items {
-      println!("{:<10} {}", &item.0, &item.1);
+    OutputKind::List => for item in items {
+      println!("{}", item);
     }
     OutputKind::Preview => {
       preview(items)?
index 28c362fcd0cad1c6fda49aa13978f3d9829db13d..b0ef0898488eb50114f112efbb54714f83135304 100644 (file)
@@ -221,6 +221,7 @@ impl OccultedPieceTrait for ItemOccultable {
 
 #[derive(Debug,Clone,Serialize,Deserialize,Eq,PartialEq,Ord,PartialOrd)]
 pub struct ItemEnquiryData {
+  pub libname: String,
   pub itemname: GoodItemName,
   pub sortkey: Option<String>,
   pub f0desc: Html,
@@ -230,7 +231,8 @@ pub struct ItemEnquiryData {
 impl Display for ItemEnquiryData {
   #[throws(fmt::Error)]
   fn fmt(&self, f: &mut Formatter) {
-    write!(f, "{:20}  {}", self.itemname, self.f0desc.as_html_str())?;
+    write!(f, "{:<10} {:20}  {}", &self.libname, &self.itemname,
+           self.f0desc.as_html_str())?;
   }
 }
 
@@ -566,6 +568,7 @@ impl Contents {
       };
       let f0bbox = loaded.bbox_approx()?;
       let ier = ItemEnquiryData {
+        libname: self.libname.clone(),
         itemname: (**k).to_owned(),
         sortkey: v.sort.to_owned(),
         f0bbox,