Rust Command Line App

김필모·2023년 11월 20일

Rustacean

목록 보기
2/4
cargo new grrs
cd grrs/
 
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
    path: std::path::PathBuf,
}

fn main() {
    let args = Cli::parse();

    println!("pattern: {:?}, path: {:?}", args.pattern, args.path)
}
cargo run

0개의 댓글