Skip to main content

jlucktay_grrs/
lib.rs

1use clap::Parser;
2
3pub fn _find_matches(
4	content: &str,
5	pattern: &str,
6	mut writer: impl std::io::Write,
7) -> std::io::Result<()> {
8	for line in content.lines() {
9		if line.contains(pattern) {
10			writeln!(writer, "{}", line)?
11		}
12	}
13
14	Ok(())
15}
16
17/// Search for a pattern in a file and display the lines that contain it.
18#[derive(Parser)]
19pub struct Cli {
20	/// The pattern to look for
21	pub pattern: String,
22
23	/// The path to the file to read
24	#[clap(parse(from_os_str))]
25	pub path: std::path::PathBuf,
26}