Skip to content

Commit 0ec379d

Browse files
committed
Add releases command to list project versions
1 parent 2c7a9b2 commit 0ec379d

12 files changed

+463
-9
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,5 @@ prove: test-password-store
9797
OSHT_VERBOSE=1 prove -v _t/*.t
9898

9999
generate:
100-
cd schemas && ./fetch-schemas.py
100+
cd schemas && go run ./fetch-schemas.go
101101
grep -h slipscheme jiradata/*.go | grep json | sort | uniq | awk -F\/\/ '{print $$2}' | while read cmd; do $$cmd; done

jiracli/templates.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"github.com/coryb/figtree"
2121
shellquote "github.com/kballard/go-shellquote"
2222
"github.com/mgutz/ansi"
23-
"github.com/olekukonko/tablewriter"
2423
wordwrap "github.com/mitchellh/go-wordwrap"
24+
"github.com/olekukonko/tablewriter"
2525
"golang.org/x/crypto/ssh/terminal"
2626
)
2727

@@ -312,6 +312,7 @@ var AllTemplates = map[string]string{
312312
"issuetypes": defaultIssuetypesTemplate,
313313
"json": defaultDebugTemplate,
314314
"list": defaultListTemplate,
315+
"releases": defaultReleasesTemplate,
315316
"request": defaultDebugTemplate,
316317
"subtask": defaultSubtaskTemplate,
317318
"table": defaultTableTemplate,
@@ -459,6 +460,9 @@ const defaultTransitionsTemplate = `{{ range .transitions }}{{.id }}: {{.name}}
459460
const defaultComponentsTemplate = `{{ range . }}{{.id }}: {{.name}}
460461
{{end}}`
461462

463+
const defaultReleasesTemplate = `{{ range . }}{{.id }}: {{.name}}
464+
{{end}}`
465+
462466
const defaultComponentAddTemplate = `{{/* compoinent add template */ -}}
463467
project: {{or .project ""}}
464468
name: {{or .name ""}}

jiracmd/registry.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func RegisterAllCommands() {
3939
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "login", Entry: CmdLoginRegistry()})
4040
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "logout", Entry: CmdLogoutRegistry()})
4141
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "rank", Entry: CmdRankRegistry()})
42+
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "releases", Entry: CmdReleasesRegistry()})
4243
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "reopen", Entry: CmdTransitionRegistry("reopen")})
4344
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "request", Entry: CmdRequestRegistry(), Aliases: []string{"req"}})
4445
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "resolve", Entry: CmdTransitionRegistry("resolve")})

jiracmd/releases.go

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package jiracmd
2+
3+
import (
4+
"github.com/coryb/figtree"
5+
"github.com/coryb/oreo"
6+
"github.com/go-jira/jira"
7+
"github.com/go-jira/jira/jiracli"
8+
kingpin "gopkg.in/alecthomas/kingpin.v2"
9+
)
10+
11+
type ReleasesOptions struct {
12+
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
13+
Project string `yaml:"project,omitempty" json:"project,omitempty"`
14+
Status []string
15+
Query string
16+
OrderBy string
17+
}
18+
19+
func CmdReleasesRegistry() *jiracli.CommandRegistryEntry {
20+
opts := ReleasesOptions{
21+
CommonOptions: jiracli.CommonOptions{
22+
Template: figtree.NewStringOption("releases"),
23+
},
24+
}
25+
26+
return &jiracli.CommandRegistryEntry{
27+
Help: "List project releases",
28+
UsageFunc: func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
29+
jiracli.LoadConfigs(cmd, fig, &opts)
30+
return CmdReleasesUsage(cmd, &opts)
31+
},
32+
ExecuteFunc: func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
33+
return CmdReleases(o, globals, &opts)
34+
},
35+
}
36+
}
37+
38+
func CmdReleasesUsage(cmd *kingpin.CmdClause, opts *ReleasesOptions) error {
39+
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
40+
jiracli.GJsonQueryUsage(cmd, &opts.CommonOptions)
41+
cmd.Flag("query", "filter the results using a literal string").Short('q').StringVar(&opts.Query)
42+
cmd.Flag("status", "list of status values used to filter the results by version status").Short('s').StringsVar(&opts.Status)
43+
cmd.Flag("order", "order the results by a field: description, name, releaseDate, sequence, startDate").StringVar(&opts.OrderBy)
44+
cmd.Arg("PROJECT", "project id or key").Required().StringVar(&opts.Project)
45+
return nil
46+
}
47+
48+
func CmdReleases(o *oreo.Client, globals *jiracli.GlobalOptions, opts *ReleasesOptions) error {
49+
data, err := jira.GetProjectVersionsPaginated(o, globals.Endpoint.Value, opts.Project, opts.Status, opts.Query, opts.OrderBy)
50+
if err != nil {
51+
return err
52+
}
53+
if err := opts.PrintTemplate(data); err != nil {
54+
return err
55+
}
56+
return nil
57+
}

jiradata/Operations.go

+34-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package jiradata
55
// https://github.com/coryb/slipscheme
66
//
77
// Generated with command:
8-
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/TransitionsMeta.json
8+
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/PageofVersion.json
99
/////////////////////////////////////////////////////////////////////////
1010
// DO NOT EDIT //
1111
/////////////////////////////////////////////////////////////////////////
@@ -15,7 +15,38 @@ package jiradata
1515
// "title": "operations",
1616
// "type": "array",
1717
// "items": {
18-
// "type": "string"
18+
// "title": "Simple Link",
19+
// "type": "object",
20+
// "properties": {
21+
// "href": {
22+
// "title": "href",
23+
// "type": "string"
24+
// },
25+
// "iconClass": {
26+
// "title": "iconClass",
27+
// "type": "string"
28+
// },
29+
// "id": {
30+
// "title": "id",
31+
// "type": "string"
32+
// },
33+
// "label": {
34+
// "title": "label",
35+
// "type": "string"
36+
// },
37+
// "styleClass": {
38+
// "title": "styleClass",
39+
// "type": "string"
40+
// },
41+
// "title": {
42+
// "title": "title",
43+
// "type": "string"
44+
// },
45+
// "weight": {
46+
// "title": "weight",
47+
// "type": "integer"
48+
// }
49+
// }
1950
// }
2051
// }
21-
type Operations []string
52+
type Operations []*SimpleLink

jiradata/PageOfVersion.go

+174
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
package jiradata
2+
3+
/////////////////////////////////////////////////////////////////////////
4+
// This Code is Generated by SlipScheme Project:
5+
// https://github.com/coryb/slipscheme
6+
//
7+
// Generated with command:
8+
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/PageofVersion.json
9+
/////////////////////////////////////////////////////////////////////////
10+
// DO NOT EDIT //
11+
/////////////////////////////////////////////////////////////////////////
12+
13+
// PageOfVersion defined from schema:
14+
// {
15+
// "title": "Page of Version",
16+
// "id": "https://docs.atlassian.com/jira/REST/schema/page-of-version#",
17+
// "type": "object",
18+
// "properties": {
19+
// "isLast": {
20+
// "title": "isLast",
21+
// "type": "boolean"
22+
// },
23+
// "maxResults": {
24+
// "title": "maxResults",
25+
// "type": "integer"
26+
// },
27+
// "nextPage": {
28+
// "title": "nextPage",
29+
// "type": "string"
30+
// },
31+
// "self": {
32+
// "title": "self",
33+
// "type": "string"
34+
// },
35+
// "startAt": {
36+
// "title": "startAt",
37+
// "type": "integer"
38+
// },
39+
// "total": {
40+
// "title": "total",
41+
// "type": "integer"
42+
// },
43+
// "values": {
44+
// "title": "values",
45+
// "type": "array",
46+
// "items": {
47+
// "title": "Version",
48+
// "type": "object",
49+
// "properties": {
50+
// "archived": {
51+
// "title": "archived",
52+
// "type": "boolean"
53+
// },
54+
// "description": {
55+
// "title": "description",
56+
// "type": "string"
57+
// },
58+
// "expand": {
59+
// "title": "expand",
60+
// "type": "string"
61+
// },
62+
// "id": {
63+
// "title": "id",
64+
// "type": "string"
65+
// },
66+
// "moveUnfixedIssuesTo": {
67+
// "title": "moveUnfixedIssuesTo",
68+
// "type": "string"
69+
// },
70+
// "name": {
71+
// "title": "name",
72+
// "type": "string"
73+
// },
74+
// "operations": {
75+
// "title": "operations",
76+
// "type": "array",
77+
// "items": {
78+
// "title": "Simple Link",
79+
// "type": "object",
80+
// "properties": {
81+
// "href": {
82+
// "title": "href",
83+
// "type": "string"
84+
// },
85+
// "iconClass": {
86+
// "title": "iconClass",
87+
// "type": "string"
88+
// },
89+
// "id": {
90+
// "title": "id",
91+
// "type": "string"
92+
// },
93+
// "label": {
94+
// "title": "label",
95+
// "type": "string"
96+
// },
97+
// "styleClass": {
98+
// "title": "styleClass",
99+
// "type": "string"
100+
// },
101+
// "title": {
102+
// "title": "title",
103+
// "type": "string"
104+
// },
105+
// "weight": {
106+
// "title": "weight",
107+
// "type": "integer"
108+
// }
109+
// }
110+
// }
111+
// },
112+
// "overdue": {
113+
// "title": "overdue",
114+
// "type": "boolean"
115+
// },
116+
// "project": {
117+
// "title": "project",
118+
// "type": "string"
119+
// },
120+
// "projectId": {
121+
// "title": "projectId",
122+
// "type": "integer"
123+
// },
124+
// "released": {
125+
// "title": "released",
126+
// "type": "boolean"
127+
// },
128+
// "remotelinks": {
129+
// "title": "remotelinks",
130+
// "type": "array",
131+
// "items": {
132+
// "title": "Remote Entity Link",
133+
// "type": "object",
134+
// "properties": {
135+
// "link": {
136+
// "title": "link"
137+
// },
138+
// "name": {
139+
// "title": "name",
140+
// "type": "string"
141+
// },
142+
// "self": {
143+
// "title": "self",
144+
// "type": "string"
145+
// }
146+
// }
147+
// }
148+
// },
149+
// "self": {
150+
// "title": "self",
151+
// "type": "string"
152+
// },
153+
// "userReleaseDate": {
154+
// "title": "userReleaseDate",
155+
// "type": "string"
156+
// },
157+
// "userStartDate": {
158+
// "title": "userStartDate",
159+
// "type": "string"
160+
// }
161+
// }
162+
// }
163+
// }
164+
// }
165+
// }
166+
type PageOfVersion struct {
167+
IsLast bool `json:"isLast,omitempty" yaml:"isLast,omitempty"`
168+
MaxResults int `json:"maxResults,omitempty" yaml:"maxResults,omitempty"`
169+
NextPage string `json:"nextPage,omitempty" yaml:"nextPage,omitempty"`
170+
Self string `json:"self,omitempty" yaml:"self,omitempty"`
171+
StartAt int `json:"startAt,omitempty" yaml:"startAt,omitempty"`
172+
Total int `json:"total,omitempty" yaml:"total,omitempty"`
173+
Values Values `json:"values,omitempty" yaml:"values,omitempty"`
174+
}

jiradata/RemoteEntityLink.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package jiradata
55
// https://github.com/coryb/slipscheme
66
//
77
// Generated with command:
8-
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/Project.json
8+
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/PageofVersion.json
99
/////////////////////////////////////////////////////////////////////////
1010
// DO NOT EDIT //
1111
/////////////////////////////////////////////////////////////////////////

jiradata/Remotelinks.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package jiradata
55
// https://github.com/coryb/slipscheme
66
//
77
// Generated with command:
8-
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/Project.json
8+
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/PageofVersion.json
99
/////////////////////////////////////////////////////////////////////////
1010
// DO NOT EDIT //
1111
/////////////////////////////////////////////////////////////////////////

jiradata/SimpleLink.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package jiradata
55
// https://github.com/coryb/slipscheme
66
//
77
// Generated with command:
8-
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/Project.json
8+
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/PageofVersion.json
99
/////////////////////////////////////////////////////////////////////////
1010
// DO NOT EDIT //
1111
/////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)