✨ feat(cli): add remove label subcommand
- add `remove-label` subcommand to remove labels from rules
This commit is contained in:
committed by
Jeremiah Russell
parent
278171503f
commit
7d55e6bbd4
23
src/cli/config_cli/label_cli/remove_cli.rs
Normal file
23
src/cli/config_cli/label_cli/remove_cli.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user