♻️ refactor(cli): rename rule management subcommands for clarity
- rename `add`, `rm`, and `action` subcommands to `add-rule`, `remove-rule`, and `set-action-on-rule` respectively to improve clarity - update corresponding modules and structs to reflect the renaming, enhancing code readability and maintainability
This commit is contained in:
committed by
Jeremiah Russell
parent
b64b2d00bd
commit
9773327e86
@@ -1,11 +1,11 @@
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
mod action_cli;
|
||||
mod add_cli;
|
||||
mod action_rule_cli;
|
||||
mod add_rule_cli;
|
||||
mod label_cli;
|
||||
mod rm_cli;
|
||||
mod rm_rule_cli;
|
||||
|
||||
use action_cli::ActionCli;
|
||||
use action_rule_cli::ActionRuleCli;
|
||||
use cull_gmail::{Result, Rules};
|
||||
use label_cli::LabelCli;
|
||||
|
||||
@@ -15,17 +15,17 @@ enum SubCmds {
|
||||
#[clap(name = "list")]
|
||||
List,
|
||||
/// Add a rules to the config file
|
||||
#[clap(name = "add")]
|
||||
Add(add_cli::AddCli),
|
||||
#[clap(name = "add-rule")]
|
||||
Add(add_rule_cli::AddRuleCli),
|
||||
/// Remove a rule from the config file
|
||||
#[clap(name = "remove", alias = "rm")]
|
||||
Remove(rm_cli::RmCli),
|
||||
#[clap(name = "remove-rule", alias = "rm")]
|
||||
Remove(rm_rule_cli::RmRuleCli),
|
||||
/// Add or remove Label from rule
|
||||
#[clap(name = "label")]
|
||||
Label(LabelCli),
|
||||
/// Set action on a specific rule
|
||||
#[clap(name = "action")]
|
||||
Action(ActionCli),
|
||||
#[clap(name = "set-action-on-rule")]
|
||||
Action(ActionRuleCli),
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
|
||||
@@ -12,7 +12,7 @@ pub enum Action {
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct ActionCli {
|
||||
pub struct ActionRuleCli {
|
||||
/// Id of the rule on which action applies
|
||||
#[clap(short, long)]
|
||||
id: usize,
|
||||
@@ -21,7 +21,7 @@ pub struct ActionCli {
|
||||
action: Action,
|
||||
}
|
||||
|
||||
impl ActionCli {
|
||||
impl ActionRuleCli {
|
||||
pub fn run(&self, mut config: Rules) -> Result<()> {
|
||||
if config.get_rule(self.id).is_none() {
|
||||
return Err(Error::RuleNotFound(self.id));
|
||||
@@ -23,7 +23,7 @@ impl fmt::Display for Period {
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddCli {
|
||||
pub struct AddRuleCli {
|
||||
/// Period for the rule
|
||||
#[arg(short, long)]
|
||||
period: Period,
|
||||
@@ -38,7 +38,7 @@ pub struct AddCli {
|
||||
delete: bool,
|
||||
}
|
||||
|
||||
impl AddCli {
|
||||
impl AddRuleCli {
|
||||
pub fn run(&self, mut config: Rules) -> Result<(), Error> {
|
||||
let generate = self.label.is_none();
|
||||
let message_age = MessageAge::new(self.period.to_string().as_str(), self.count)?;
|
||||
@@ -2,7 +2,7 @@ use clap::Parser;
|
||||
use cull_gmail::{Error, Rules};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct RmCli {
|
||||
pub struct RmRuleCli {
|
||||
/// Id of the rule to remove
|
||||
#[clap(short, long)]
|
||||
id: Option<usize>,
|
||||
@@ -11,7 +11,7 @@ pub struct RmCli {
|
||||
label: Option<String>,
|
||||
}
|
||||
|
||||
impl RmCli {
|
||||
impl RmRuleCli {
|
||||
pub fn run(&self, mut config: Rules) -> Result<(), Error> {
|
||||
if self.id.is_none() && self.label.is_none() {
|
||||
return Err(Error::NoRuleSelector);
|
||||
Reference in New Issue
Block a user