feat(cli): add remove label subcommand

- add `remove-label` subcommand to remove labels from rules
This commit is contained in:
Jeremiah Russell
2025-10-09 14:40:35 +01:00
committed by Jeremiah Russell
parent 278171503f
commit 7d55e6bbd4
2 changed files with 23 additions and 50 deletions

View File

@@ -0,0 +1,23 @@
use clap::Parser;
use cull_gmail::{Config, Error, Result};
#[derive(Debug, Parser)]
pub struct RemoveCli {
/// Id of the rule on which action applies
#[clap(short, long)]
id: usize,
/// Label to remove from the rule
#[clap(short, long)]
label: String,
}
impl RemoveCli {
pub fn run(&self, mut config: Config) -> Result<()> {
if config.get_rule(self.id).is_none() {
return Err(Error::RuleNotFound(self.id));
}
config.remove_label_from_rule(self.id, &self.label)
}
}