diff --git a/src/list_cli.rs b/src/list_cli.rs new file mode 100644 index 0000000..6e7b3f7 --- /dev/null +++ b/src/list_cli.rs @@ -0,0 +1,32 @@ +use clap::Parser; +use google_gmail1::{ + Error, Gmail, hyper_rustls::HttpsConnector, hyper_util::client::legacy::connect::HttpConnector, +}; + +/// Command line options for the list subcommand +#[derive(Debug, Parser)] +pub struct ListCli {} + +impl ListCli { + pub(crate) async fn run(&self, hub: Gmail>) { + let result = hub.users().messages_list("me").doit().await; + + match result { + Err(e) => match e { + // The Error enum provides details about what exactly happened. + // You can also just use its `Debug`, `Display` or `Error` traits + Error::HttpError(_) + | Error::Io(_) + | Error::MissingAPIKey + | Error::MissingToken(_) + | Error::Cancelled + | Error::UploadSizeLimitExceeded(_, _) + | Error::Failure(_) + | Error::BadRequest(_) + | Error::FieldClash(_) + | Error::JsonDecodeError(_, _) => println!("{e}"), + }, + Ok(res) => println!("Success: {res:?}"), + } + } +}