From 66dd0dc9836c704e3c5b699532d25c69a3681e51 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Thu, 9 Oct 2025 12:24:12 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(config):=20add=20remove=20labe?= =?UTF-8?q?l=20from=20rule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - implement remove_label_from_rule function to delete labels from rules - add error handling for rule not found - save configuration after removing the label --- src/config.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/config.rs b/src/config.rs index 0edc293..929c5be 100644 --- a/src/config.rs +++ b/src/config.rs @@ -161,6 +161,18 @@ impl Config { Ok(()) } + /// Remove a label from the rule identified by the id + pub fn remove_label_from_rule(&mut self, id: usize, label: &str) -> Result<()> { + let Some(rule) = self.rules.get_mut(id.to_string().as_str()) else { + return Err(Error::RuleNotFound(id)); + }; + rule.remove_label(label); + self.save()?; + println!("Label `{label}` removed from rule `#{id}`"); + + Ok(()) + } + /// Save the current configuration to the file pub fn save(&self) -> Result<()> { let home_dir = env::home_dir().unwrap();