mirror of
https://github.com/orhun/git-cliff.git
synced 2024-09-11 06:55:38 +03:00
feat(output): support using stdout via dash (-o -
) (#644)
This commit is contained in:
parent
6f7b399b42
commit
df81f636f5
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user