✨ feat(config): add remove label from rule
- implement remove_label_from_rule function to delete labels from rules - add error handling for rule not found - save configuration after removing the label
This commit is contained in:
committed by
Jeremiah Russell
parent
eaa7d4be12
commit
66dd0dc983
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user