work
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 13 Oct 2025 02:36:57 +0000 (19:36 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 13 Oct 2025 02:36:57 +0000 (19:36 -0700)
rust/pspp/src/output.rs
rust/pspp/src/show_spv.rs

index 913c8756e58a6e86669be09b6720edd80ed6608b..1ac438c77a2a3f896c5bee596c79751b69b8bd5b 100644 (file)
@@ -807,7 +807,7 @@ pub struct Criteria(pub Vec<Selection>);
 impl Criteria {
     /// Returns a new output item whose children are all the (direct and
     /// indirect) children of `item` that meet the criteria.
-    pub fn apply(&self, item: Item) -> Item {
+    pub fn apply(&self, mut item: Item) -> Item {
         fn take_children(item: &Item) -> Vec<&Item> {
             item.details.children().iter().map(|item| &**item).collect()
         }
@@ -924,7 +924,7 @@ impl Criteria {
             }
         }
         fn unflatten_item(mut item: Item, include: &mut bit_vec::Iter, out: &mut Vec<Arc<Item>>) {
-            let include_item = include.next().unwrap_or_default(); //XXX should just be unwrap
+            let include_item = include.next().unwrap();
             if let Some(children) = item.details.mut_children() {
                 if !include_item {
                     unflatten_items(take(children), include, out);
@@ -951,7 +951,11 @@ impl Criteria {
         }
 
         let mut output = Vec::new();
-        unflatten_item(item, &mut include.iter(), &mut output);
+        unflatten_items(
+            take(item.details.mut_children().unwrap()),
+            &mut include.iter(),
+            &mut output,
+        );
         Heading(output).into_item().with_label("Output")
     }
 }
@@ -1081,12 +1085,12 @@ struct SelectionArgs {
     instances: Vec<usize>,
 
     /// Include hidden objects in the output (by default, they are excluded)
-    #[arg(long, required = false, action = ArgAction::Append)]
+    #[arg(long, required = false, action = ArgAction::Append, num_args = 0, value_parser = value_parser!(bool), default_missing_value = "true", default_value = "false")]
     show_hidden: bool,
 
     /// Include only objects that cause an error when read (by default, objects
     /// with and without errors are included).
-    #[arg(long, required = false, action = ArgAction::Append)]
+    #[arg(long, required = false, action = ArgAction::Append, num_args = 0, value_parser = value_parser!(bool), default_missing_value = "true", default_value = "false")]
     errors: bool,
 
     /// Include only XML and binary member names that match.  Without any member
index fafe045eacb275259cd353ef3602f711b30965d1..c2a0fd94b6384430df3464e1efa705b3f6c48f17 100644 (file)
@@ -77,7 +77,7 @@ impl ShowSpv {
         match self.mode {
             Mode::Directory => {
                 let item = Item::from_spv_file(&self.input)?.0;
-                //let item = self.criteria.apply(item);
+                let item = self.criteria.apply(item);
                 for child in item.details.children() {
                     print_item_directory(&child, 0, self.show_member_names);
                 }