diff --git a/git-cliff-core/src/lib.rs b/git-cliff-core/src/lib.rs index 0b1278aaf4..e46e5bc27b 100644 --- a/git-cliff-core/src/lib.rs +++ b/git-cliff-core/src/lib.rs @@ -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"; diff --git a/git-cliff/src/args.rs b/git-cliff/src/args.rs index 9972fcf113..c82a26e9a1 100644 --- a/git-cliff/src/args.rs +++ b/git-cliff/src/args.rs @@ -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; @@ -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, /// Sets the tag for the latest version. diff --git a/website/docs/usage/examples.md b/website/docs/usage/examples.md index 2d7980e646..ce5bb9d668 100644 --- a/website/docs/usage/examples.md +++ b/website/docs/usage/examples.md @@ -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: diff --git a/website/docs/usage/usage.md b/website/docs/usage/usage.md index 53c28ffeb5..8e04d42611 100644 --- a/website/docs/usage/usage.md +++ b/website/docs/usage/usage.md @@ -33,7 +33,7 @@ git-cliff [FLAGS] [OPTIONS] [--] [RANGE] --exclude-path ... Sets the path to exclude related commits [env: GIT_CLIFF_EXCLUDE_PATH=] --with-commit ... Sets custom commit messages to include in the changelog [env: GIT_CLIFF_WITH_COMMIT=] -p, --prepend Prepends entries to the given changelog file [env: GIT_CLIFF_PREPEND=] --o, --output Writes output to the given file [env: GIT_CLIFF_OUTPUT=] +-o, --output [] Writes output to the given file [env: GIT_CLIFF_OUTPUT=] -t, --tag Sets the tag for the latest version [env: GIT_CLIFF_TAG=] -b, --body