diff --git a/src/main.rs b/src/main.rs index b679ef3..75e5510 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,11 @@ use clap::{Parser, Subcommand}; +mod list_cli; + +use cull_gmail::Credential; +use google_gmail1::{Gmail, yup_oauth2::ApplicationSecret}; +use list_cli::ListCli; + #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] struct Cli { @@ -13,16 +19,17 @@ struct Cli { enum Commands { /// List messages #[clap(name = "list")] - List, + List(ListCli), } -fn main() { +#[tokio::main] +async fn main() { let args = Cli::parse(); let mut logging = get_logging(args.logging.log_level_filter()); logging.init(); - run(args); + run(args).await; // match run(args) { // Ok(_) => {} // Err(e) => { @@ -38,10 +45,17 @@ fn main() { // } } -fn run(args: Cli) { +async fn run(args: Cli) { + let secret: ApplicationSecret = Credential::load_json_file("credential.json").into(); + + let auth = cull_gmail::get_auth(secret).await; + let client = cull_gmail::get_client(); + + let hub = Gmail::new(client, auth); + if let Some(cmds) = args.command { match cmds { - Commands::List => todo!(), + Commands::List(list_cli) => list_cli.run(hub).await, } } // Ok(())