clap/examples/demo.rs

25 lines
472 B
Rust
Raw Normal View History

// Note: this requires the `derive` attribute
2021-12-07 21:34:23 +00:00
use clap::Parser;
/// Simple program to greet a person
#[derive(Parser, Debug)]
#[clap(about, version, author)]
struct Args {
/// Name of the person to greet
#[clap(short, long)]
name: String,
/// Number of times to greet
#[clap(short, long, default_value_t = 1)]
count: u8,
}
2021-11-30 03:05:42 +00:00
fn main() {
2021-12-07 21:34:23 +00:00
let args = Args::parse();
2021-11-30 03:05:42 +00:00
2021-12-07 21:34:23 +00:00
for _ in 0..args.count {
println!("Hello {}!", args.name)
}
2021-11-30 03:05:42 +00:00
}