-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathassignee.go
51 lines (42 loc) · 950 Bytes
/
assignee.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"log"
"github.com/urfave/cli"
)
func AssigneeCommand() cli.Command {
command := cli.Command{
Name: "assignee",
Aliases: []string{"a"},
Usage: "change assignee",
Flags: []cli.Flag{
cli.BoolFlag{Name: "reporter, r"},
cli.StringFlag{Name: "jql, j"},
cli.StringFlag{Name: "issue, i"},
cli.StringFlag{Name: "user, u"},
},
Action: func(c *cli.Context) error {
jc, err := NewClient()
if err != nil {
panic(err)
}
jql := c.String("jql")
issueKey := c.String("issue")
user := c.String("user")
reporter := c.Bool("reporter")
issues, err := jc.findIssues(jql, issueKey)
for _, issue := range *issues {
var err error
if reporter {
err = jc.UpdateAssignee(issue.Key, &(issue.Fields.Creator.Name))
} else {
err = jc.UpdateAssignee(issue.Key, &user)
}
if err != nil {
log.Println(err)
}
}
return nil
},
}
return command
}