♻️ refactor(cli): restructure cli commands and config handling
- rename config cli to rules cli for better clarity - move config loading to rules cli for better modularity - update command matching to use the new rules cli
This commit is contained in:
committed by
Jeremiah Russell
parent
90383226aa
commit
bebf00acb4
14
src/main.rs
14
src/main.rs
@@ -1,14 +1,14 @@
|
|||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
mod config_cli;
|
|
||||||
mod label_cli;
|
mod label_cli;
|
||||||
mod message_cli;
|
mod message_cli;
|
||||||
|
mod rules_cli;
|
||||||
mod trash_cli;
|
mod trash_cli;
|
||||||
|
|
||||||
use config_cli::ConfigCli;
|
|
||||||
use cull_gmail::{Config, Error};
|
use cull_gmail::{Config, Error};
|
||||||
use label_cli::LabelCli;
|
use label_cli::LabelCli;
|
||||||
use message_cli::MessageCli;
|
use message_cli::MessageCli;
|
||||||
|
use rules_cli::RulesCli;
|
||||||
use std::error::Error as stdError;
|
use std::error::Error as stdError;
|
||||||
|
|
||||||
use trash_cli::TrashCli;
|
use trash_cli::TrashCli;
|
||||||
@@ -34,8 +34,8 @@ enum Commands {
|
|||||||
#[clap(name = "trash")]
|
#[clap(name = "trash")]
|
||||||
Trash(TrashCli),
|
Trash(TrashCli),
|
||||||
/// Configure end-of-life rules
|
/// Configure end-of-life rules
|
||||||
#[clap(name = "config")]
|
#[clap(name = "rules")]
|
||||||
Config(ConfigCli),
|
Rules(RulesCli),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@@ -66,9 +66,9 @@ async fn run(args: Cli) -> Result<(), Error> {
|
|||||||
if let Some(cmds) = args.command {
|
if let Some(cmds) = args.command {
|
||||||
match cmds {
|
match cmds {
|
||||||
Commands::Message(list_cli) => list_cli.run(config.credential_file()).await?,
|
Commands::Message(list_cli) => list_cli.run(config.credential_file()).await?,
|
||||||
Commands::Labels(label_cli) => label_cli.run("credential.json").await?,
|
Commands::Labels(label_cli) => label_cli.run(config.credential_file()).await?,
|
||||||
Commands::Trash(trash_cli) => trash_cli.run("credential.json").await?,
|
Commands::Trash(trash_cli) => trash_cli.run(config.credential_file()).await?,
|
||||||
Commands::Config(config_cli) => config_cli.run(),
|
Commands::Rules(config_cli) => config_cli.run(config),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user