use anyhow::{Context, Result};
use clap::Parser;
#[derive(Parser)]
struct Cli {
pattern: String,
path: std::path::PathBuf,
}
fn main() -> Result<()> {
let args = Cli::parse();
let content = std::fs::read_to_string(&args.path)
.with_context(|| format!("could not read file `{}`", args.path.display()))?;
rust_cli_tool_grrs::find_matches(&content, &args.pattern, &mut std::io::stdout());
Ok(())
}
#[test]
fn find_a_match() {
let mut result = Vec::new();
rust_cli_tool_grrs::find_matches("lorem ipsum\ndolor si amet", "lorem", &mut result);
assert_eq!(result, b"lorem ipsum\n");
}