forked from go-jira/jira
/
issuelinktypes.go
41 lines (36 loc) · 1.19 KB
/
issuelinktypes.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
package jiracmd
import (
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
func CmdIssueLinkTypesRegistry() *jiracli.CommandRegistryEntry {
opts := jiracli.CommonOptions{
Template: figtree.NewStringOption("issuelinktypes"),
}
return &jiracli.CommandRegistryEntry{
"Show the issue link types",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdIssueLinkTypesUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdIssueLinkTypes(o, globals, &opts)
},
}
}
func CmdIssueLinkTypesUsage(cmd *kingpin.CmdClause, opts *jiracli.CommonOptions) error {
jiracli.TemplateUsage(cmd, opts)
jiracli.GJsonQueryUsage(cmd, opts)
return nil
}
// CmdIssueLinkTypes will get issue link type data and send to "issuelinktypes" template
func CmdIssueLinkTypes(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.CommonOptions) error {
data, err := jira.GetIssueLinkTypes(o, globals.Endpoint.Value)
if err != nil {
return err
}
return opts.PrintTemplate(data)
}