use clap::Parser;
use std::io::BufRead;
use anyhow::{Context, Result};
use std::io::{self};
use indicatif::ProgressBar;
#[derive(Parser)]
struct Cli {
pattern: String,
path: std::path::PathBuf
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Cli::parse();
let file = std::fs::File::open(&args.path)
.with_context(|| format!("could not read file `{}`", &args.path.display()))?;
let reader = std::io::BufReader::new(file);
let stdout = io::stdout(); let handle = stdout.lock(); let mut writer = io::BufWriter::new(handle); let pb = ProgressBar::new(100);
grrs_bj::find_matches(reader, &pb, &args.pattern, &mut writer)?;
pb.finish_with_message("done");
Ok(())
}