♻️ refactor(cli): move rules_cli to config_cli

- move rules_cli to config_cli for better organization
This commit is contained in:
Jeremiah Russell
2025-10-09 14:40:02 +01:00
committed by Jeremiah Russell
parent ce27475269
commit 12ce3a2fd8

View File

@@ -0,0 +1,38 @@
use clap::{Parser, Subcommand};
use cull_gmail::{Config, Error};
mod add_cli;
mod rm_cli;
use add_cli::AddCli;
use rm_cli::RmCli;
#[derive(Debug, Subcommand)]
pub enum RulesCommands {
/// List the rules configured and saved in the config file
#[clap(name = "list")]
List,
/// Add a rules to the config file
#[clap(name = "add")]
Add(AddCli),
/// Remove a rule from the config file
#[clap(name = "remove", alias = "rm")]
Remove(RmCli),
}
#[derive(Debug, Parser)]
pub struct RulesCli {
/// Configuration commands
#[command(subcommand)]
command: RulesCommands,
}
impl RulesCli {
pub fn run(&self, config: Config) -> Result<(), Error> {
match &self.command {
RulesCommands::List => config.list_rules(),
RulesCommands::Add(add_cli) => add_cli.run(config),
RulesCommands::Remove(rm_cli) => rm_cli.run(config),
}
}
}