Skip to content

Commit

Permalink
feat(args): set CHANGELOG.md as default missing value for output op…
Browse files Browse the repository at this point in the history
…tion (#354)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
sh-cho and mergify[bot] committed Nov 22, 2023
1 parent 425d31e commit 04d149e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions git-cliff-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ extern crate log;

/// Default configuration file.
pub const DEFAULT_CONFIG: &str = "cliff.toml";
/// Default output file.
pub const DEFAULT_OUTPUT: &str = "CHANGELOG.md";
9 changes: 7 additions & 2 deletions git-cliff/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use clap::{
Parser,
ValueEnum,
};
use git_cliff_core::DEFAULT_CONFIG;
use git_cliff_core::{
DEFAULT_CONFIG,
DEFAULT_OUTPUT,
};
use glob::Pattern;
use std::path::PathBuf;

Expand Down Expand Up @@ -130,7 +133,9 @@ pub struct Opt {
long,
env = "GIT_CLIFF_OUTPUT",
value_name = "PATH",
value_parser = Opt::parse_dir
value_parser = Opt::parse_dir,
num_args = 0..=1,
default_missing_value = DEFAULT_OUTPUT
)]
pub output: Option<PathBuf>,
/// Sets the tag for the latest version.
Expand Down
4 changes: 4 additions & 0 deletions website/docs/usage/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ git cliff --topo-order
Save the changelog file to the specified file:

```bash
# Set output path
git cliff --output CHANGELOG.md

# Without path, the default is `CHANGELOG.md`
git cliff -o
```

Print the changelog [context](/docs/templating/context) as JSON:
Expand Down
2 changes: 1 addition & 1 deletion website/docs/usage/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ git-cliff [FLAGS] [OPTIONS] [--] [RANGE]
--exclude-path <PATTERN>... Sets the path to exclude related commits [env: GIT_CLIFF_EXCLUDE_PATH=]
--with-commit <MSG>... Sets custom commit messages to include in the changelog [env: GIT_CLIFF_WITH_COMMIT=]
-p, --prepend <PATH> Prepends entries to the given changelog file [env: GIT_CLIFF_PREPEND=]
-o, --output <PATH> Writes output to the given file [env: GIT_CLIFF_OUTPUT=]
-o, --output [<PATH>] Writes output to the given file [env: GIT_CLIFF_OUTPUT=]
-t, --tag <TAG> Sets the tag for the latest version [env: GIT_CLIFF_TAG=]
-b, --body <TEMPLATE> Sets the template for the changelog body [env: GIT_CLIFF_TEMPLATE=]
-s, --strip <PART> Strips the given parts from the changelog [possible values: header, footer, all]
Expand Down

0 comments on commit 04d149e

Please sign in to comment.