feat(rules_cli): add optional label for retention rules

- allows users to specify a custom label when adding a retention rule
- if no label is provided, a unique one will be generated automatically
This commit is contained in:
Jeremiah Russell
2025-10-08 11:33:43 +01:00
committed by Jeremiah Russell
parent 432c1635af
commit 4830d95a76

View File

@@ -30,16 +30,18 @@ pub struct AddCli {
/// Count of the period
#[arg(short, long, default_value = "1")]
count: usize,
/// Flag to indicate that a label should be generated
/// Optional specific label; if not specified one will be generated
#[arg(short, long)]
generate: bool,
label: Option<String>,
}
impl AddCli {
pub fn run(&self, mut config: Config) -> Result<(), Error> {
let generate = self.label.is_none();
let message_age = MessageAge::new(self.period.to_string().as_str(), self.count);
let retention = Retention::new(message_age, self.generate);
config.add_rule(retention);
let retention = Retention::new(message_age, generate);
config.add_rule(retention, self.label.as_ref());
config.save()
}
}