summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@sequoia-pgp.org>2022-09-29 16:28:53 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2022-09-29 16:28:53 +0300
commit841ca3667e6971ef924a0c4367ec03a0f96c7a71 (patch)
tree050285d4803c0334fea79125a35adf66a2605ffa
parentdd00bbcce0f93ad682c161e2459bd1716d2a0211 (diff)
downloadenterprise-hello-841ca3667e6971ef924a0c4367ec03a0f96c7a71.tar.gz
allow user to specify who gets greeted
Sponsored-by: author
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs11
2 files changed, 11 insertions, 1 deletions
diff --git a/Cargo.toml b/Cargo.toml
index b586046..eb81e2f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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,
}