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();
}
async fn load_config_file(config: Config) -> Result<Config, AnyError> {
match config.config_file.as_ref() {
async fn load_config_file(opt: Config) -> Result<Config, AnyError> {
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<Config, AnyError> {
e
),
};
config.dry_run |= opt.dry_run;
Ok(config)
}
None => Ok(config),
None => Ok(opt),
}
}

Loading…
Cancel
Save