♻️ refactor(cli): remove config from run args

- remove config from run args to load inside functions
- load credential.json directly instead of config file
This commit is contained in:
Jeremiah Russell
2025-10-15 13:47:25 +01:00
committed by Jeremiah Russell
parent 455007dd82
commit 5905a6fb54
4 changed files with 27 additions and 16 deletions

View File

@@ -31,11 +31,11 @@ pub struct ConfigCli {
}
impl ConfigCli {
pub fn run(&self, config: Rules) -> Result<()> {
pub fn run(&self, rules: Rules) -> 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),
SubCmds::Rules(rules_cli) => rules_cli.run(rules),
SubCmds::Label(label_cli) => label_cli.run(rules),
SubCmds::Action(action_cli) => action_cli.run(rules),
}
}
}

View File

@@ -15,11 +15,11 @@ pub struct RunCli {
}
impl RunCli {
pub async fn run(&self, client: &mut GmailClient, config: Rules) -> Result<()> {
let rules = config.get_rules_by_label();
pub async fn run(&self, client: &mut GmailClient, rules: Rules) -> Result<()> {
let rules_by_labels = rules.get_rules_by_label();
for label in config.labels() {
let Some(rule) = rules.get(&label) else {
for label in rules.labels() {
let Some(rule) = rules_by_labels.get(&label) else {
log::warn!("no rule found for label `{label}`");
continue;
};