Browse Source

set `dry_run` to `true` in `Config` if passed as command line flag

feat/mass-publish-tool
Jonathan Strong 1 year ago
parent
commit
315c27b25b
  1. 9
      src/main.rs

9
src/main.rs

@ -376,12 +376,12 @@ fn setup_logger() {
builder.init(); builder.init();
} }
async fn load_config_file(config: Config) -> Result<Config, AnyError> { async fn load_config_file(opt: Config) -> Result<Config, AnyError> {
match config.config_file.as_ref() { match opt.config_file.as_ref() {
Some(path) => { Some(path) => {
debug!(?path, "loading config file"); debug!(?path, "loading config file");
let toml = tokio::fs::read_to_string(&path).await?; 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, Ok(c) => c,
Err(e) => panic!( Err(e) => panic!(
"\nfatal error: parsing config file at {} failed:\n\n{}\n\n", "\nfatal error: parsing config file at {} failed:\n\n{}\n\n",
@ -389,10 +389,11 @@ async fn load_config_file(config: Config) -> Result<Config, AnyError> {
e e
), ),
}; };
config.dry_run |= opt.dry_run;
Ok(config) Ok(config)
} }
None => Ok(config), None => Ok(opt),
} }
} }

Loading…
Cancel
Save