1
1
mirror of https://github.com/orhun/git-cliff.git synced 2024-08-16 02:10:29 +03:00

feat(output): support using stdout via dash (-o -) (#644)

This commit is contained in:
Orhun Parmaksız 2024-05-18 13:17:48 +03:00 committed by GitHub
parent 6f7b399b42
commit df81f636f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,6 +48,7 @@ use std::io::{
self,
Write,
};
use std::path::PathBuf;
use std::time::{
SystemTime,
UNIX_EPOCH,
@ -498,7 +499,11 @@ pub fn run(mut args: Opt) -> Result<()> {
changelog.prepend(fs::read_to_string(path)?, &mut File::create(path)?)?;
}
if let Some(path) = args.output {
let mut output = File::create(path)?;
let mut output: Box<dyn Write> = if path == PathBuf::from("-") {
Box::new(io::stdout())
} else {
Box::new(File::create(path)?)
};
if args.context {
changelog.write_context(&mut output)
} else {