follwing rust tutorial
This commit is contained in:
parent
835752580a
commit
d8c21fefb2
@ -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"] }
|
||||
|
20
src/main.rs
20
src/main.rs
@ -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()
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user