feat(cli): load configurations from toml file

- load configurations from `cull-gmail.toml`
- set default value for rules in config
This commit is contained in:
Jeremiah Russell
2025-10-16 11:00:38 +01:00
committed by Jeremiah Russell
parent 1ae34efb93
commit 44b98d0657

View File

@@ -87,12 +87,13 @@ fn get_logging(level: log::LevelFilter) -> env_logger::Builder {
fn get_config() -> Result<ClientConfig> { fn get_config() -> Result<ClientConfig> {
let home_dir = env::home_dir().unwrap(); let home_dir = env::home_dir().unwrap();
let path = home_dir.join(".cull-gmail/rules.toml"); let path = home_dir.join(".cull-gmail/cull-gmail.toml");
log::trace!("Loading config from {}", path.display()); log::info!("Loading config from {}", path.display());
let configurations = config::Config::builder() let configurations = config::Config::builder()
.set_default("credentials", "credential.json")? .set_default("credentials", "credential.json")?
.set_default("config_root", "h:.cull-gmail")? .set_default("config_root", "h:.cull-gmail")?
.set_default("rules", "rules.toml")?
// Add in `./Settings.toml` // Add in `./Settings.toml`
.add_source(config::File::with_name( .add_source(config::File::with_name(
path.to_path_buf().to_str().unwrap(), path.to_path_buf().to_str().unwrap(),