✨ 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:
committed by
Jeremiah Russell
parent
432c1635af
commit
4830d95a76
@@ -30,16 +30,18 @@ pub struct AddCli {
|
|||||||
/// Count of the period
|
/// Count of the period
|
||||||
#[arg(short, long, default_value = "1")]
|
#[arg(short, long, default_value = "1")]
|
||||||
count: usize,
|
count: usize,
|
||||||
/// Flag to indicate that a label should be generated
|
/// Optional specific label; if not specified one will be generated
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
generate: bool,
|
label: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddCli {
|
impl AddCli {
|
||||||
pub fn run(&self, mut config: Config) -> Result<(), Error> {
|
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 message_age = MessageAge::new(self.period.to_string().as_str(), self.count);
|
||||||
let retention = Retention::new(message_age, self.generate);
|
let retention = Retention::new(message_age, generate);
|
||||||
config.add_rule(retention);
|
|
||||||
|
config.add_rule(retention, self.label.as_ref());
|
||||||
config.save()
|
config.save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user