Skip to content

Commit

Permalink
Add a --file flag (#9)
Browse files Browse the repository at this point in the history
Adds a flag allowing the user to specify the Changelog file to read
from.
  • Loading branch information
rgreinho authored Jan 7, 2020
1 parent e7ebb4f commit 1b4ef87
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [[1.2.0]] - 2020.01.06

### Added

- Add a flag allowing the user to specify the Changelog file to read from.

## [[1.1.2]] - 2019.12.30

### Fixed
Expand Down
5 changes: 4 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ var rootCmd = &cobra.Command{
// Get the flags.
extract, err := cmd.Flags().GetBool("extract")
utils.Check(err)
file, err := cmd.Flags().GetString("file")
utils.Check(err)

// Read the last release information from the Changelog.
title, content, err := keeparelease.ReadChangelog("")
title, content, err := keeparelease.ReadChangelog(file)
utils.Check(err)

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

func uploadAssets(gh *github.Client, release *github.Release, assets []string) {
Expand Down
3 changes: 0 additions & 3 deletions keeparelease/keeparelease.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ func ParseChangelog(changelog string) (title, content string, err error) {
// ReadChangelog reads the changelog file.
// Returns the title of the last release as well as its content.
func ReadChangelog(file string) (title, content string, err error) {
if file == "" {
file = "CHANGELOG.md"
}
dat, err := ioutil.ReadFile(file)
if err != nil {
return "", "", err
Expand Down

0 comments on commit 1b4ef87

Please sign in to comment.