Files
cull-gmail/src/config_cli.rs
Jeremiah Russell 40ea9e52f4 ♻️ refactor(cli): rename command to sub_command for clarity
- rename `command` field to `sub_command` in `Cli` and `ConfigCli` structs
- rename `Commands` enum to `SubCmds` to reflect its role as subcommand
- update references to the renamed fields and enum variants
- this improves code readability and avoids confusion with other command concepts

🐛 fix(config): correct method name for setting eol action

- rename `set_command` to `set_action` in `EolRule` struct
- update references in `config.rs` to use the correct method name
- this fixes a bug where the eol action was not being set correctly
2025-10-09 14:30:21 +01:00

42 lines
989 B
Rust

use clap::{Parser, Subcommand};
mod action_cli;
mod label_cli;
mod rules_cli;
use action_cli::ActionCli;
use cull_gmail::{Config, Result};
use label_cli::LabelCli;
use rules_cli::RulesCli;
#[derive(Subcommand, Debug)]
enum SubCmds {
/// Configure end-of-life rules
#[clap(name = "rules")]
Rules(RulesCli),
/// Add or remove Label from rule
#[clap(name = "label")]
Label(LabelCli),
/// Set action on a specific rule
#[clap(name = "action")]
Action(ActionCli),
}
#[derive(Parser, Debug)]
pub struct ConfigCli {
#[clap(flatten)]
logging: clap_verbosity_flag::Verbosity,
#[command(subcommand)]
sub_command: SubCmds,
}
impl ConfigCli {
pub fn run(&self, config: Config) -> Result<()> {
match &self.sub_command {
SubCmds::Rules(rules_cli) => rules_cli.run(config),
SubCmds::Label(label_cli) => label_cli.run(config),
SubCmds::Action(action_cli) => action_cli.run(config),
}
}
}