♻️ refactor(cli): move rm_cli to new directory

- move the rm_cli module from src/config_cli/rules_cli/ to src/cli/config_cli/rules_cli/
This commit is contained in:
Jeremiah Russell
2025-10-09 14:40:48 +01:00
committed by Jeremiah Russell
parent 7d55e6bbd4
commit 801628310b

View File

@@ -0,0 +1,32 @@
use clap::Parser;
use cull_gmail::{Config, Error};
#[derive(Debug, Parser)]
pub struct RmCli {
/// Id of the rule to remove
#[clap(short, long)]
id: Option<usize>,
/// Label in the rule to remove (the rule will be removed)
#[clap(short, long)]
label: Option<String>,
}
impl RmCli {
pub fn run(&self, mut config: Config) -> Result<(), Error> {
if self.id.is_none() && self.label.is_none() {
return Err(Error::NoRuleSelector);
}
if let Some(id) = self.id {
config.remove_rule_by_id(id)?;
config.save()?;
}
if let Some(label) = &self.label {
config.remove_rule_by_label(label)?;
config.save()?;
}
Ok(())
}
}