From d8c21fefb2c734c4d712fdf017f3ea1daf302130 Mon Sep 17 00:00:00 2001 From: crunk Date: Sun, 10 Sep 2023 17:37:43 +0200 Subject: [PATCH] follwing rust tutorial --- Cargo.toml | 1 + src/main.rs | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index a8b166a..0a61e6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,4 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap = { version = "4.0", features = ["derive"] } diff --git a/src/main.rs b/src/main.rs index e7a11a9..f4c09ca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,19 @@ +#![allow(unused)] +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() { - println!("Hello, world!"); + let args = Cli::parse(); + println!("pattern: {}", args.pattern); + println!( + "path: {}", + args.path.into_os_string().into_string().unwrap() + ); }