feat(cli): add optional rules path argument to cli

- allow users to specify a rules file path via command line argument
- update run_with_rules_path to prioritize cli argument over config file
This commit is contained in:
Jeremiah Russell
2025-10-31 08:01:34 +00:00
committed by Jeremiah Russell
parent 14c7d6435e
commit bf8d1c3cf4

View File

@@ -102,7 +102,7 @@
//! - **Logging system**: Comprehensive operation tracking //! - **Logging system**: Comprehensive operation tracking
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
use std::path::Path; use std::path::{Path, PathBuf};
mod config_cli; mod config_cli;
mod run_cli; mod run_cli;
@@ -210,6 +210,7 @@ pub struct RulesCli {
/// Each subcommand provides specialized functionality for its domain. /// Each subcommand provides specialized functionality for its domain.
#[command(subcommand)] #[command(subcommand)]
sub_command: SubCmds, sub_command: SubCmds,
rules: Option<PathBuf>,
} }
impl RulesCli { impl RulesCli {
@@ -275,8 +276,14 @@ impl RulesCli {
pub async fn run_with_rules_path( pub async fn run_with_rules_path(
&self, &self,
client: &mut GmailClient, client: &mut GmailClient,
rules_path: Option<&Path>, mut rules_path: Option<&Path>,
) -> Result<()> { ) -> Result<()> {
log::info!("Rules path: {rules_path:?}");
if let Some(p) = &self.rules {
rules_path = Some(p.as_path());
}
log::info!("Rules path: {rules_path:?}");
let rules = get_rules_from(rules_path)?; let rules = get_rules_from(rules_path)?;
match &self.sub_command { match &self.sub_command {