1
1
mirror of https://github.com/orhun/git-cliff.git synced 2024-12-13 23:32:24 +03:00

feat(changelog): allow running with --prepend and --output (#120)

This commit is contained in:
Orhun Parmaksız 2022-12-16 20:59:32 +03:00
parent 53c1c50a1e
commit 7325be8404
No known key found for this signature in database
GPG Key ID: F83424824B3E4B90

View File

@ -292,19 +292,21 @@ pub fn run(mut args: Opt) -> Result<()> {
}
}
// Generate changelog.
// Generate output.
let changelog = Changelog::new(releases, &config)?;
if args.context {
return changelog.write_context(&mut io::stdout());
}
if let Some(path) = args.prepend {
changelog.prepend(fs::read_to_string(&path)?, &mut File::create(path)?)
} else if let Some(path) = args.output {
changelog.prepend(fs::read_to_string(&path)?, &mut File::create(path)?)?;
}
if let Some(path) = args.output {
let mut output = File::create(path)?;
if args.context {
changelog.write_context(&mut output)
} else {
changelog.generate(&mut output)
}
} else if args.context {
changelog.write_context(&mut io::stdout())
} else {
changelog.generate(&mut io::stdout())
}