Skip to content

Commit

Permalink
Print matching search term occurrences
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanfrishkorn committed Sep 9, 2023
1 parent 16b71e6 commit 975cf5f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,11 +701,20 @@ fn main() -> Result<(), Box<dyn Error>> {
};

// print to stderr to keep redirection clean
eprint!("{} document", search_results.items.len());
eprint!("document");
if search_results.items.len() != 1 {
eprint!("s");
}
eprintln!(" found");
eprint!(": {}", search_results.items.len());
// print count of matched terms
let mut term_match_count = 0;
for item in &search_results.items {
for m in &item.matches {
term_match_count += m.1.len();
}
}
eprint!(" occurrences: {}", term_match_count);
eprintln!();

// check to see if results are present
if search_results.items.is_empty() {
Expand Down

0 comments on commit 975cf5f

Please sign in to comment.