feat(rules): add subcommand for rule management

- introduce RulesCli to handle rule management commands
- implement `add` subcommand with `AddCli` to add rules to the config
This commit is contained in:
Jeremiah Russell
2025-10-08 07:53:41 +01:00
committed by Jeremiah Russell
parent 92e88c4261
commit b729ee6a10

View File

@@ -1,5 +1,9 @@
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
use cull_gmail::Config; use cull_gmail::{Config, Error};
mod add_cli;
use add_cli::AddCli;
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
pub struct RulesCli { pub struct RulesCli {
@@ -9,10 +13,10 @@ pub struct RulesCli {
} }
impl RulesCli { impl RulesCli {
pub fn run(&self, config: Config) { pub fn run(&self, config: Config) -> Result<(), Error> {
match self.command { match &self.command {
RulesCommands::List => config.list_rules(), RulesCommands::List => config.list_rules(),
RulesCommands::Add => todo!(), RulesCommands::Add(add_cli) => add_cli.run(config),
RulesCommands::Remove => todo!(), RulesCommands::Remove => todo!(),
RulesCommands::Update => todo!(), RulesCommands::Update => todo!(),
} }
@@ -26,7 +30,7 @@ pub enum RulesCommands {
List, List,
/// Add a rules to the config file /// Add a rules to the config file
#[clap(name = "add")] #[clap(name = "add")]
Add, Add(AddCli),
/// Remove a rule from the config file /// Remove a rule from the config file
#[clap(name = "remove", alias = "rm")] #[clap(name = "remove", alias = "rm")]
Remove, Remove,