| 86 | } |
| 87 | |
| 88 | fn output_count(&self, selectors: &QuerySelectorList) -> CliResult { |
| 89 | let bump = Bump::default(); |
| 90 | let mut total = 0; |
| 91 | let mut files = 0; |
| 92 | |
| 93 | for (filename, mut source) in self.input.sources()? { |
| 94 | let mut src = String::new(); |
| 95 | source.read_to_string(&mut src)?; |
| 96 | |
| 97 | let lexer = Lexer::new(&CssAtomSet::ATOMS, &src); |
| 98 | let mut parser = Parser::new(&bump, &src, lexer); |
| 99 | let Some(stylesheet) = parser.parse_entirely::<StyleSheet>().output else { continue }; |
| 100 | let count = SelectorMatcher::new(selectors, &self.selector, &src).run(&stylesheet).count(); |
| 101 | if count == 0 { |
| 102 | continue; |
| 103 | } |
| 104 | |
| 105 | println!("{filename}:{count}"); |
| 106 | files += 1; |
| 107 | total += count; |
| 108 | } |
| 109 | |
| 110 | if files > 1 { |
| 111 | println!("\nTotal: {total}"); |
| 112 | } |
| 113 | |
| 114 | Ok(()) |
| 115 | } |
| 116 | |
| 117 | fn suggest_types(&self, input: &str) { |
| 118 | let type_name = input.split(|c: char| c == ':' || c.is_whitespace()).next().unwrap_or(input); |