use coincidence::*;
|
|
use std::io::Read;
|
|
|
|
fn main() {
|
|
let mut args = std::env::args();
|
|
|
|
if let Some(filepath) = args.nth(1) {
|
|
let jewlist = get_jew_list();
|
|
|
|
let mut file = std::fs::File::open(filepath).expect("you fucked up the filepath retard");
|
|
let mut buf = String::new();
|
|
|
|
file.read_to_string(&mut buf)
|
|
.expect("somehow failed to read from string");
|
|
|
|
let spans: Vec<Span> = Detector::new(&buf, &jewlist).collect();
|
|
|
|
for (idx, c) in buf.char_indices() {
|
|
let mut is_jewish = false;
|
|
|
|
for span in &spans {
|
|
if idx >= span.start && idx <= span.end {
|
|
is_jewish = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
let color = if is_jewish { "\x1b[31m" } else { "\x1b[0m" };
|
|
|
|
print!("{}{}", color, c);
|
|
}
|
|
} else {
|
|
print!("Nice argument retard");
|
|
}
|
|
println!();
|
|
}
|