Skip to content

Commit 1b4ef87

Browse files
authored
Add a --file flag (#9)
Adds a flag allowing the user to specify the Changelog file to read from.
1 parent e7ebb4f commit 1b4ef87

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [[1.2.0]] - 2020.01.06
11+
12+
### Added
13+
14+
- Add a flag allowing the user to specify the Changelog file to read from.
15+
1016
## [[1.1.2]] - 2019.12.30
1117

1218
### Fixed

cmd/root.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ var rootCmd = &cobra.Command{
2424
// Get the flags.
2525
extract, err := cmd.Flags().GetBool("extract")
2626
utils.Check(err)
27+
file, err := cmd.Flags().GetString("file")
28+
utils.Check(err)
2729

2830
// Read the last release information from the Changelog.
29-
title, content, err := keeparelease.ReadChangelog("")
31+
title, content, err := keeparelease.ReadChangelog(file)
3032
utils.Check(err)
3133

3234
// If extract only, simply display the content of the last release.
@@ -81,6 +83,7 @@ func init() {
8183
rootCmd.Flags().BoolP("extract", "x", false, "Only extract the last release information")
8284
rootCmd.Flags().StringP("tag", "t", "", "Use a specific tag")
8385
rootCmd.Flags().StringArrayP("attach", "a", []string{}, "Specify the assets to include into the release")
86+
rootCmd.Flags().StringP("file", "f", "CHANGELOG.md", "Specify a changelog file")
8487
}
8588

8689
func uploadAssets(gh *github.Client, release *github.Release, assets []string) {

keeparelease/keeparelease.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ func ParseChangelog(changelog string) (title, content string, err error) {
6464
// ReadChangelog reads the changelog file.
6565
// Returns the title of the last release as well as its content.
6666
func ReadChangelog(file string) (title, content string, err error) {
67-
if file == "" {
68-
file = "CHANGELOG.md"
69-
}
7067
dat, err := ioutil.ReadFile(file)
7168
if err != nil {
7269
return "", "", err

0 commit comments

Comments
 (0)