1use crate::cli::{Cli, ReportingMode};
2use crate::math::combinations;
3use crate::types::JsonRoot;
4
5use std::thread;
6use std::sync::mpsc;
7
8pub fn spawn_processing_text(args: &Cli, rx: mpsc::Receiver<bool>) {
12 if !args.verbose {
13 return;
14 }
15
16 let total = combinations(args.files.len(), 2) + args.files.len();
17 thread::spawn(move || {
18 let mut i = 1usize;
19 for _ in rx {
20 let percentage = i * 100 / total;
21 eprint!("{percentage}% completed\r");
22
23 i += 1;
24 }
25 eprintln!();
26 });
27}
28
29pub fn matches(args: &Cli, matches: &JsonRoot) {
30 match args.reporting_mode {
31 ReportingMode::Json => {
32 println!("{}", matches.json());
33 }
34 ReportingMode::Text => {
35 println!("{matches}");
36 }
37 }
38}
39
40pub fn conclusion(args: &Cli, matches: &JsonRoot) {
41 if args.verbose {
42 eprintln!(
43 "A total of {} unique match(es) were found in the {} file(s).",
44 matches.unique_matches(),
45 args.files.len()
46 );
47 }
48}