summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index 423a643..6bb5758 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,19 @@
-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: pattern,
- path: std::path::PathBuf::from(path),
-};
+#![allow(unused)]
+///Using clap - command line argument parser
+use clap::Parser;
+
+/// Search for a pattern in a file and display the lines that contain it.
+#[derive(Parser)]
+struct Cli {
+ /// The pattern to look for
+ pattern: String,
+ /// The path to the file to read
+ #[clap(parse(from_os_str))]
+ path: std::path::PathBuf,
+}
+
+fn main() {
+ let args = Cli::parse();
+}
+
+