Browse Source

close and reopening of issues

Signed-off-by: Erik Hollensbe <github@hollensbe.org>
master
Erik Hollensbe 3 years ago
parent
commit
c94a701845
  1. 38
      barb/issue.go
  2. 12
      barb/main.go

38
barb/issue.go

@ -173,3 +173,41 @@ func replyIssue(ctx *cli.Context) {
fmt.Println("Comment posted!")
}
func reopenIssue(ctx *cli.Context) {
editIssue(ctx, "opened")
}
func closeIssue(ctx *cli.Context) {
editIssue(ctx, "closed")
}
func editIssue(ctx *cli.Context, state string) {
args := ctx.Args()
if len(args) != 1 {
exitError(errors.New("invalid arguments"))
}
client := getClient()
num, err := strconv.Atoi(args[0])
if err != nil {
exitError(err)
}
owner, repo, err := repo()
if err != nil {
exitError(err)
}
_, _, err = client.Issues.Edit(context.Background(), owner, repo, num, &github.IssueRequest{
State: github.String(state),
})
if err != nil {
exitError(err)
}
fmt.Println("Issue", num, state+"!")
}

12
barb/main.go

@ -16,6 +16,18 @@ func main() {
ShortName: "i",
Usage: "Subcommand trampoline for all issues",
Subcommands: []cli.Command{
{
Name: "reopen",
Usage: "reopen an issue",
ArgsUsage: "[id]",
Action: reopenIssue,
},
{
Name: "close",
Usage: "close an issue",
ArgsUsage: "[id]",
Action: closeIssue,
},
{
Name: "get",
Usage: "get info on a single issue",

Loading…
Cancel
Save