Skip to content

Commit

Permalink
feat(cli): add synergy between init and config flags
Browse files Browse the repository at this point in the history
  • Loading branch information
xsadia committed Dec 25, 2024
1 parent e85888f commit 9453b45
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ use std::fs::{
File,
};
use std::io;
use std::path::Path;
use std::path::{
Path,
PathBuf,
};
use std::time::{
SystemTime,
UNIX_EPOCH,
Expand Down Expand Up @@ -376,12 +379,19 @@ pub fn run(mut args: Opt) -> Result<()> {
Some(ref name) => BuiltinConfig::get_config(name.to_string())?,
None => EmbeddedConfig::get_config()?,
};

let output_path = if args.config == PathBuf::from(DEFAULT_CONFIG) {
PathBuf::from(DEFAULT_CONFIG)
} else {
args.config.clone()
};

info!(
"Saving the configuration file{} to {:?}",
init_config.map(|v| format!(" ({v})")).unwrap_or_default(),
DEFAULT_CONFIG
output_path
);
fs::write(DEFAULT_CONFIG, contents)?;
fs::write(output_path, contents)?;
return Ok(());
}

Expand Down

0 comments on commit 9453b45

Please sign in to comment.