Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(args): set CHANGELOG.md as default missing value for output option #354

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading