aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2021-05-22 20:18:59 +0200
committerTeddy Wing2021-05-22 20:18:59 +0200
commit4df1a2f8776a62230c6bdc291dfd8149bd4ef0fb (patch)
treed10c027e86ab15d4d19ea881d5626c20f0f827ab /src
parent0bbbf8886a765961169c2fa239d0d838165022d7 (diff)
downloadgoogle-calendar-rsvp-4df1a2f8776a62230c6bdc291dfd8149bd4ef0fb.tar.bz2
Add `--help` and `--version` command line arguments
Diffstat (limited to 'src')
-rw-r--r--src/main.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index dfcdd7b..fb5853c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -49,6 +49,23 @@ async fn main() {
}
}
+fn print_usage() {
+ println!(r#"
+usage: google-calendar-rsvp [options] [-y | -n | -m] [--email] [event_ids...]
+
+Options:
+ -y, --yes rsvp with "yes"
+ -n, --no rsvp with "no"
+ -m, --maybe rsvp with "maybe"
+
+ --email read a Google Calendar invitation email from stdin
+
+ -v, --verbose enable verbose output
+ -h, --help print this help menu
+ -V, --version show the program version
+"#);
+}
+
async fn run() -> anyhow::Result<()> {
let args: Vec<String> = env::args().collect();
@@ -76,6 +93,16 @@ async fn run() -> anyhow::Result<()> {
"-v" | "--verbose" =>
is_verbose = true,
+ "-h" | "--help" => {
+ print_usage();
+ process::exit(exitcode::USAGE);
+ },
+
+ "-V" | "--version" => {
+ println!("{}", env!("CARGO_PKG_VERSION"));
+ process::exit(exitcode::OK);
+ },
+
id =>
event_ids.push(id),
}