From 315c27b25b537184abbb1eab20c07517bc03bb57 Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Fri, 3 Nov 2023 03:55:45 -0400 Subject: [PATCH] set `dry_run` to `true` in `Config` if passed as command line flag --- src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index c277efc..7dd429d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -376,12 +376,12 @@ fn setup_logger() { builder.init(); } -async fn load_config_file(config: Config) -> Result { - match config.config_file.as_ref() { +async fn load_config_file(opt: Config) -> Result { + match opt.config_file.as_ref() { Some(path) => { debug!(?path, "loading config file"); let toml = tokio::fs::read_to_string(&path).await?; - let config: Config = match toml::from_str(&toml) { + let mut config: Config = match toml::from_str(&toml) { Ok(c) => c, Err(e) => panic!( "\nfatal error: parsing config file at {} failed:\n\n{}\n\n", @@ -389,10 +389,11 @@ async fn load_config_file(config: Config) -> Result { e ), }; + config.dry_run |= opt.dry_run; Ok(config) } - None => Ok(config), + None => Ok(opt), } }