diff options
author | Lars Wirzenius <liw@sequoia-pgp.org> | 2022-09-29 16:28:53 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@sequoia-pgp.org> | 2022-09-29 16:28:53 +0300 |
commit | 841ca3667e6971ef924a0c4367ec03a0f96c7a71 (patch) | |
tree | 050285d4803c0334fea79125a35adf66a2605ffa | |
parent | dd00bbcce0f93ad682c161e2459bd1716d2a0211 (diff) | |
download | enterprise-hello-841ca3667e6971ef924a0c4367ec03a0f96c7a71.tar.gz |
allow user to specify who gets greeted
Sponsored-by: author
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/main.rs | 11 |
2 files changed, 11 insertions, 1 deletions
@@ -6,3 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap = { version = "4.0.2", features = ["derive"] } diff --git a/src/main.rs b/src/main.rs index e7a11a9..d1d7e5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,12 @@ +use clap::Parser; + fn main() { - println!("Hello, world!"); + let args = Args::parse(); + println!("hello, {}", args.whom); +} + +#[derive(Parser)] +struct Args { + #[clap(default_value = "world")] + whom: String, } |