Skip to content

Commit

Permalink
feat(args): add --output argument
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Jun 18, 2021
1 parent e6fb8de commit e0cda23
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ git-cliff [FLAGS] [OPTIONS] [RANGE]
-w, --workdir <PATH> Sets the working directory [env: WORKDIR=]
-r, --repository <PATH> Sets the repository to parse commits from [env: REPOSITORY=]
-p, --changelog <PATH> Prepends entries to the given changelog file [env: CHANGELOG=]
-o, --output <PATH> Writes output to the given file [env: OUTPUT=]
-t, --tag <TAG> Sets the tag for the latest version [env: TAG=]
-s, --strip <PART> Strips the given parts from the changelog [possible values: header, footer, all]
```
Expand Down
3 changes: 3 additions & 0 deletions git-cliff/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ pub struct Opt {
/// Prepends entries to the given changelog file.
#[structopt(short = "p", long, env, value_name = "PATH")]
pub changelog: Option<PathBuf>,
/// Writes output to the given file.
#[structopt(short, long, env, value_name = "PATH")]
pub output: Option<PathBuf>,
/// Sets the tag for the latest version.
#[structopt(short, long, env, value_name = "TAG", allow_hyphen_values = true)]
pub tag: Option<String>,
Expand Down
2 changes: 2 additions & 0 deletions git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ pub fn run(mut args: Opt) -> Result<()> {
let changelog = Changelog::new(releases, &config)?;
if let Some(path) = args.changelog {
changelog.prepend(fs::read_to_string(&path)?, &mut File::create(path)?)
} else if let Some(path) = args.output {
changelog.generate(&mut File::create(path)?)
} else {
changelog.generate(&mut io::stdout())
}
Expand Down

0 comments on commit e0cda23

Please sign in to comment.