From 6e23ccc0cc78081f9f56b41056175b3d5b8aafdb Mon Sep 17 00:00:00 2001 From: Ian Rettig Date: Fri, 6 Jun 2025 13:17:01 -0400 Subject: [PATCH] Feat: Create simple grep function. --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 634f087..686c351 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,5 +10,11 @@ struct Cli { fn main() { let args = Cli::parse(); - println!("pattern: {:?}, path: {:?}", args.pattern, args.path) + let content = std::fs::read_to_string(&args.path).expect("Could not read file."); + + for line in content.lines() { + if line.contains(&args.pattern) { + println!("{}", line) + } + } }