Skip to content

Commit

Permalink
feat(changelog): support setting the body template via args
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Jun 20, 2021
1 parent 027521c commit 9fc08f4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ git-cliff [FLAGS] [OPTIONS] [RANGE]
-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=]
-b, --body <TEMPLATE> Sets the template for the changelog body [env: TEMPLATE=]
-s, --strip <PART> Strips the given parts from the changelog [possible values: header, footer, all]
```

Expand Down
17 changes: 15 additions & 2 deletions git-cliff/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,28 @@ pub struct Opt {
/// Sets the tag for the latest version.
#[structopt(short, long, env, value_name = "TAG", allow_hyphen_values = true)]
pub tag: Option<String>,
/// Sets the template for the changelog body.
#[structopt(
short,
long,
env = "TEMPLATE",
value_name = "TEMPLATE",
allow_hyphen_values = true
)]
pub body: Option<String>,
/// Processes the commits starting from the latest tag.
#[structopt(short, long)]
pub latest: bool,
/// Processes the commits that do not belong to a tag.
#[structopt(short, long)]
pub unreleased: bool,
/// Strips the given parts from the changelog.
#[structopt(short, long, value_name = "PART",
possible_values = &["header", "footer", "all"])]
#[structopt(
short,
long,
value_name = "PART",
possible_values = &["header", "footer", "all"]
)]
pub strip: Option<String>,
/// Sets the commit range to process.
#[structopt(value_name = "RANGE")]
Expand Down
3 changes: 3 additions & 0 deletions git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ pub fn run(mut args: Opt) -> Result<()> {
)));
}
}
if let Some(template) = args.body {
config.changelog.body = template;
}

// Initialize the git repository.
let repository =
Expand Down

0 comments on commit 9fc08f4

Please sign in to comment.