Feat: Use clap for argument parsing.

This commit is contained in:
Ian Rettig
2025-06-06 12:18:53 -04:00
parent f28b89e7f9
commit 892fd43b53
+5 -7
View File
@@ -1,16 +1,14 @@
use clap::Parser;
// Search for a pattern in a file and display the lines that contain it.
#[derive(Parser)]
struct Cli {
pattern: String,
path: std::path::PathBuf,
}
fn main() {
let pattern = std::env::args().nth(1).expect("no pattern given.");
let path = std::env::args().nth(2).expect("no path given.");
let args = Cli {
pattern,
path: std::path::PathBuf::from(path),
};
let args = Cli::parse();
println!("pattern: {:?}, path: {:?}", args.pattern, args.path)
}