feat(cli): implement list subcommand

- add `list` subcommand using clap
- integrate google_gmail1 crate for Gmail API interaction
- add credential loading and authentication flow
This commit is contained in:
Jeremiah Russell
2025-10-01 09:59:12 +01:00
committed by Jeremiah Russell
parent 89fee7bf48
commit af0ddab54a

View File

@@ -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(())