Skip to content

Commit

Permalink
feat(output): support using stdout via dash (-o -) (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun authored May 18, 2024
1 parent 6f7b399 commit df81f63
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use std::io::{
self,
Write,
};
use std::path::PathBuf;
use std::time::{
SystemTime,
UNIX_EPOCH,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit df81f63

Please sign in to comment.