From b729ee6a1064756c438308d31d2b7718a10479c5 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Wed, 8 Oct 2025 07:53:41 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(rules):=20add=20subcommand=20f?= =?UTF-8?q?or=20rule=20management?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - introduce RulesCli to handle rule management commands - implement `add` subcommand with `AddCli` to add rules to the config --- src/rules_cli.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/rules_cli.rs b/src/rules_cli.rs index 08f819e..d81215c 100644 --- a/src/rules_cli.rs +++ b/src/rules_cli.rs @@ -1,5 +1,9 @@ use clap::{Parser, Subcommand}; -use cull_gmail::Config; +use cull_gmail::{Config, Error}; + +mod add_cli; + +use add_cli::AddCli; #[derive(Debug, Parser)] pub struct RulesCli { @@ -9,10 +13,10 @@ pub struct RulesCli { } impl RulesCli { - pub fn run(&self, config: Config) { - match self.command { + pub fn run(&self, config: Config) -> Result<(), Error> { + match &self.command { RulesCommands::List => config.list_rules(), - RulesCommands::Add => todo!(), + RulesCommands::Add(add_cli) => add_cli.run(config), RulesCommands::Remove => todo!(), RulesCommands::Update => todo!(), } @@ -26,7 +30,7 @@ pub enum RulesCommands { List, /// Add a rules to the config file #[clap(name = "add")] - Add, + Add(AddCli), /// Remove a rule from the config file #[clap(name = "remove", alias = "rm")] Remove,