♻️ 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:
committed by
Jeremiah Russell
parent
455007dd82
commit
5905a6fb54
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user