aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 55cc21b..ae42e82 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,17 +1,39 @@
+use getopts::Options;
use google_calendar3::api::{Event, EventAttendee};
-use google_calendar3::{CalendarHub, Result, Error};
+use google_calendar3::CalendarHub;
use home;
use hyper;
use hyper_rustls;
use tokio;
use yup_oauth2 as oauth2;
+use std::env;
use std::fs;
+use std::process;
#[tokio::main]
-async fn main() {
+async fn main() -> Result<(), Box<dyn std::error::Error>> {
+ let args: Vec<String> = env::args().collect();
+
+ let mut opts = Options::new();
+ opts.optflag("y", "yes", "accept invitation");
+ opts.optflag("n", "no", "decline invitation");
+ opts.optflag("m", "maybe", "tentatively accept invitation");
+
+ opts.optflag("", "email", "read an email from standard input");
+
+ let opt_matches = opts.parse(&args[1..])?;
+
+ if opt_matches.free.is_empty() {
+ eprintln!("error: missing event ID argument");
+
+ process::exit(exitcode::USAGE);
+ }
+
rsvp().await;
+
+ Ok(())
}
async fn rsvp() {