Feat: Create simple grep function.
This commit is contained in:
+7
-1
@@ -10,5 +10,11 @@ struct Cli {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let args = Cli::parse();
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user