✨ feat(cli): add list subcommand
- Implement list subcommand to display Gmail messages - Use google_gmail1 crate to interact with Gmail API
This commit is contained in:
committed by
Jeremiah Russell
parent
e607e0a6d3
commit
420ca81f51
32
src/list_cli.rs
Normal file
32
src/list_cli.rs
Normal file
@@ -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<HttpsConnector<HttpConnector>>) {
|
||||
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:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user