diff --git a/git-cliff/src/args.rs b/git-cliff/src/args.rs index ad6fb9a1..5268f954 100644 --- a/git-cliff/src/args.rs +++ b/git-cliff/src/args.rs @@ -44,9 +44,9 @@ pub struct Opt { /// Processes the commits that do not belong to a tag. #[structopt(short, long)] pub unreleased: bool, - /// Strips the header and footer from the changelog. - #[structopt(short, long)] - pub strip: bool, + /// Strips the given parts from the changelog. + #[structopt(short, long, possible_values = &["header", "footer", "all"])] + pub strip: Option, /// Sets the commit range to process. pub range: Option, } diff --git a/git-cliff/src/main.rs b/git-cliff/src/main.rs index 6c27af21..5987f958 100644 --- a/git-cliff/src/main.rs +++ b/git-cliff/src/main.rs @@ -25,10 +25,21 @@ fn main() -> Result<()> { pretty_env_logger::init(); let mut config = Config::parse(args.config)?; - if args.strip { - config.changelog.header = None; - config.changelog.footer = None; - } else if args.changelog.is_some() { + match args.strip.as_deref() { + Some("header") => { + config.changelog.header = None; + } + Some("footer") => { + config.changelog.footer = None; + } + Some("all") => { + config.changelog.header = None; + config.changelog.footer = None; + } + _ => {} + } + + if args.changelog.is_some() { config.changelog.footer = None; }