Browse Source

follwing rust tutorial

main
crunk 1 year ago
parent
commit
d8c21fefb2
  1. 1
      Cargo.toml
  2. 18
      src/main.rs

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

18
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()
);
}

Loading…
Cancel
Save