follwing rust tutorial

This commit is contained in:
crunk 2023-09-10 17:37:43 +02:00
parent 835752580a
commit d8c21fefb2
2 changed files with 19 additions and 2 deletions

View File

@ -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"] }

View File

@ -1,3 +1,19 @@
fn main() {
println!("Hello, world!");
#![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() {
let args = Cli::parse();
println!("pattern: {}", args.pattern);
println!(
"path: {}",
args.path.into_os_string().into_string().unwrap()
);
}