-
Notifications
You must be signed in to change notification settings - Fork 327
/
epicAdd.go
54 lines (44 loc) · 1.53 KB
/
epicAdd.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
52
53
54
package jiracmd
import (
"fmt"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type EpicAddOptions struct {
jiradata.EpicIssues `yaml:",inline" json:",inline" figtree:",inline"`
Epic string `yaml:"epic,omitempty" json:"epic,omitempty"`
}
func CmdEpicAddRegistry() *jiracli.CommandRegistryEntry {
opts := EpicAddOptions{}
return &jiracli.CommandRegistryEntry{
"Add issues to Epic",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdEpicAddUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdEpicAdd(o, globals, &opts)
},
}
}
func CmdEpicAddUsage(cmd *kingpin.CmdClause, opts *EpicAddOptions) error {
cmd.Arg("EPIC", "Epic Key or ID to add issues to").Required().StringVar(&opts.Epic)
cmd.Arg("ISSUE", "Issues to add to epic").Required().StringsVar(&opts.Issues)
return nil
}
func CmdEpicAdd(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EpicAddOptions) error {
if err := jira.EpicAddIssues(o, globals.Endpoint.Value, opts.Epic, &opts.EpicIssues); err != nil {
return err
}
if !globals.Quiet.Value {
fmt.Printf("OK %s %s/browse/%s\n", opts.Epic, globals.Endpoint.Value, opts.Epic)
for _, issue := range opts.Issues {
fmt.Printf("OK %s %s/browse/%s\n", issue, globals.Endpoint.Value, issue)
}
}
return nil
}