From df81f636f53e63d305d06944ff014a21612cb666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sat, 18 May 2024 13:17:48 +0300 Subject: [PATCH] feat(output): support using stdout via dash (`-o -`) (#644) --- git-cliff/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-cliff/src/lib.rs b/git-cliff/src/lib.rs index 51c63a7564..3f69c25165 100644 --- a/git-cliff/src/lib.rs +++ b/git-cliff/src/lib.rs @@ -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 = if path == PathBuf::from("-") { + Box::new(io::stdout()) + } else { + Box::new(File::create(path)?) + }; if args.context { changelog.write_context(&mut output) } else {