Skip to content

Commit

Permalink
release, edit: support description from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
aktau committed Mar 26, 2017
1 parent 00f9462 commit 3058c29
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ func releasecmd(opt Options) error {
return err
}

// Check if we need to read the description from stdin.
if desc == "-" {
b, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return fmt.Errorf("could not read description from stdin: %v", err)
}
desc = string(b)
}

params := ReleaseCreate{
TagName: tag,
TargetCommitish: target,
Expand Down Expand Up @@ -323,6 +332,15 @@ func editcmd(opt Options) error {

vprintf("release %v has id %v\n", tag, id)

// Check if we need to read the description from stdin.
if desc == "-" {
b, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return fmt.Errorf("could not read description from stdin: %v", err)
}
desc = string(b)
}

/* the release create struct works for editing releases as well */
params := ReleaseCreate{
TagName: tag,
Expand Down
4 changes: 2 additions & 2 deletions github-release.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Options struct {
Repo string `goptions:"-r, --repo, description='Github repo (required if $GITHUB_REPO not set)'"`
Tag string `goptions:"-t, --tag, obligatory, description='Git tag to create a release from'"`
Name string `goptions:"-n, --name, description='Name of the release (defaults to tag)'"`
Desc string `goptions:"-d, --description, description='Description of the release (defaults to tag)'"`
Desc string `goptions:"-d, --description, description='Release description, use - for reading a description from stdin (defaults to tag)'"`
Target string `goptions:"-c, --target, description='Commit SHA or branch to create release of (defaults to the repository default branch)'"`
Draft bool `goptions:"--draft, description='The release is a draft'"`
Prerelease bool `goptions:"-p, --pre-release, description='The release is a pre-release'"`
Expand All @@ -51,7 +51,7 @@ type Options struct {
Repo string `goptions:"-r, --repo, description='Github repo (required if $GITHUB_REPO not set)'"`
Tag string `goptions:"-t, --tag, obligatory, description='Git tag to edit the release of'"`
Name string `goptions:"-n, --name, description='New name of the release (defaults to tag)'"`
Desc string `goptions:"-d, --description, description='New description of the release (defaults to tag)'"`
Desc string `goptions:"-d, --description, description='New release description, use - for reading a description from stdin (defaults to tag)'"`
Draft bool `goptions:"--draft, description='The release is a draft'"`
Prerelease bool `goptions:"-p, --pre-release, description='The release is a pre-release'"`
} `goptions:"edit"`
Expand Down

0 comments on commit 3058c29

Please sign in to comment.