Spaces:
Runtime error
Runtime error
File size: 562 Bytes
5142f69 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
use clap::Parser;
use std::{env, thread, time::Duration};
#[derive(Debug, Parser)]
#[command(author, version, about, long_about = None)]
struct Args {
#[arg(long, short)]
message: String,
#[arg(long, short, default_value_t = 10)]
wait: u8,
}
fn main() {
let Args { message, wait } = Args::parse();
let name = env::var("MY_NAME").unwrap_or(String::from("world"));
println!("Hello, {name}!");
println!("Message: {message}");
println!("Will wait for {wait} seconds");
thread::sleep(Duration::from_secs(wait as u64));
}
|