add issuelinktypes command

This commit is contained in:
Cory Bennett
2017-08-13 22:38:22 -07:00
parent aacc9f44e4
commit 37f81a4631
4 changed files with 104 additions and 9 deletions
+4 -9
View File
@@ -128,6 +128,10 @@ func main() {
Command: "issuelink",
Entry: cli.CmdIssueLinkRegistry(),
},
jiracli.CommandRegistry{
Command: "issuelinktypes",
Entry: cli.CmdIssueLinkTypesRegistry(),
},
jiracli.CommandRegistry{
Command: "transition",
Aliases: []string{"trans"},
@@ -230,7 +234,6 @@ func main() {
// jira take ISSUE
// jira (assign|give) ISSUE [ASSIGNEE|--default]
// jira unassign ISSUE
// jira issuelinktypes
// jira transmeta ISSUE
// jira add component [-p PROJECT] NAME DESCRIPTION LEAD
// jira components [-p PROJECT]
@@ -296,13 +299,7 @@ func main() {
// "take": "take",
// "assign": "assign",
// "give": "assign",
// "fields": "fields",
// "issuelinktypes": "issuelinktypes",
// "transmeta": "transmeta",
// "editmeta": "editmeta",
// "issuetypes": "issuetypes",
// "createmeta": "createmeta",
// "transitions": "transitions",
// "export-templates": "export-templates",
// "browse": "browse",
// "req": "request",
@@ -456,8 +453,6 @@ func main() {
// var err error
// switch command {
// case "issuelinktypes":
// err = c.CmdIssueLinkTypes()
// case "issuetypes":
// err = c.CmdIssueTypes()
// case "watch":
+20
View File
@@ -295,3 +295,23 @@ func (j *Jira) TransitionIssue(issue string, iup IssueUpdateProvider) error {
}
return responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issueLinkType-getIssueLinkTypes
func (j *Jira) GetIssueLinkTypes() (*jiradata.IssueLinkTypes, error) {
uri := fmt.Sprintf("%s/rest/api/2/issueLinkType", j.Endpoint)
resp, err := j.UA.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := struct {
IssueLinkTypes jiradata.IssueLinkTypes
}{
IssueLinkTypes: jiradata.IssueLinkTypes{},
}
return &results.IssueLinkTypes, readJSON(resp.Body, &results)
}
return nil, responseError(resp)
}
+36
View File
@@ -0,0 +1,36 @@
package jiracli
import kingpin "gopkg.in/alecthomas/kingpin.v2"
func (jc *JiraCli) CmdIssueLinkTypesRegistry() *CommandRegistryEntry {
opts := GlobalOptions{
Template: "issuelinktypes",
}
return &CommandRegistryEntry{
"Show the issue link types",
func() error {
return jc.CmdIssueLinkTypes(&opts)
},
func(cmd *kingpin.CmdClause) error {
return jc.CmdIssueLinkTypesUsage(cmd, &opts)
},
}
}
func (jc *JiraCli) CmdIssueLinkTypesUsage(cmd *kingpin.CmdClause, opts *GlobalOptions) error {
if err := jc.GlobalUsage(cmd, opts); err != nil {
return err
}
jc.TemplateUsage(cmd, opts)
return nil
}
// CmdIssueLinkTypes will get issue link type data and send to "issuelinktypes" template
func (jc *JiraCli) CmdIssueLinkTypes(opts *GlobalOptions) error {
data, err := jc.GetIssueLinkTypes()
if err != nil {
return err
}
return jc.runTemplate(opts.Template, data, nil)
}
+44
View File
@@ -0,0 +1,44 @@
package jiradata
/////////////////////////////////////////////////////////////////////////
// This Code is Generated by SlipScheme Project:
// https://github.com/coryb/slipscheme
//
// Generated with command:
// slipscheme -dir jiradata -pkg jiradata schemas/IssueLinkTypes.json
/////////////////////////////////////////////////////////////////////////
// DO NOT EDIT //
/////////////////////////////////////////////////////////////////////////
// IssueLinkTypes defined from schema:
// {
// "title": "issueLinkTypes",
// "type": "array",
// "items": {
// "title": "Issue Link Type",
// "type": "object",
// "properties": {
// "id": {
// "title": "id",
// "type": "string"
// },
// "inward": {
// "title": "inward",
// "type": "string"
// },
// "name": {
// "title": "name",
// "type": "string"
// },
// "outward": {
// "title": "outward",
// "type": "string"
// },
// "self": {
// "title": "self",
// "type": "string"
// }
// }
// }
// }
type IssueLinkTypes []*IssueLinkType