Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add releases command to list project versions #410

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ prove: test-password-store
OSHT_VERBOSE=1 prove -v _t/*.t

generate:
cd schemas && ./fetch-schemas.py
cd schemas && go run ./fetch-schemas.go
grep -h slipscheme jiradata/*.go | grep json | sort | uniq | awk -F\/\/ '{print $$2}' | while read cmd; do $$cmd; done
6 changes: 5 additions & 1 deletion jiracli/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/coryb/figtree"
shellquote "github.com/kballard/go-shellquote"
"github.com/mgutz/ansi"
"github.com/olekukonko/tablewriter"
wordwrap "github.com/mitchellh/go-wordwrap"
"github.com/olekukonko/tablewriter"
"golang.org/x/crypto/ssh/terminal"
)

Expand Down Expand Up @@ -312,6 +312,7 @@ var AllTemplates = map[string]string{
"issuetypes": defaultIssuetypesTemplate,
"json": defaultDebugTemplate,
"list": defaultListTemplate,
"releases": defaultReleasesTemplate,
"request": defaultDebugTemplate,
"subtask": defaultSubtaskTemplate,
"table": defaultTableTemplate,
Expand Down Expand Up @@ -459,6 +460,9 @@ const defaultTransitionsTemplate = `{{ range .transitions }}{{.id }}: {{.name}}
const defaultComponentsTemplate = `{{ range . }}{{.id }}: {{.name}}
{{end}}`

const defaultReleasesTemplate = `{{ range . }}{{.id }}: {{.name}}
{{end}}`

const defaultComponentAddTemplate = `{{/* compoinent add template */ -}}
project: {{or .project ""}}
name: {{or .name ""}}
Expand Down
1 change: 1 addition & 0 deletions jiracmd/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func RegisterAllCommands() {
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "login", Entry: CmdLoginRegistry()})
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "logout", Entry: CmdLogoutRegistry()})
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "rank", Entry: CmdRankRegistry()})
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "releases", Entry: CmdReleasesRegistry()})
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "reopen", Entry: CmdTransitionRegistry("reopen")})
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "request", Entry: CmdRequestRegistry(), Aliases: []string{"req"}})
jiracli.RegisterCommand(jiracli.CommandRegistry{Command: "resolve", Entry: CmdTransitionRegistry("resolve")})
Expand Down
57 changes: 57 additions & 0 deletions jiracmd/releases.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package jiracmd

import (
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)

type ReleasesOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
Status []string
Query string
OrderBy string
}

func CmdReleasesRegistry() *jiracli.CommandRegistryEntry {
opts := ReleasesOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("releases"),
},
}

return &jiracli.CommandRegistryEntry{
Help: "List project releases",
UsageFunc: func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdReleasesUsage(cmd, &opts)
},
ExecuteFunc: func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdReleases(o, globals, &opts)
},
}
}

func CmdReleasesUsage(cmd *kingpin.CmdClause, opts *ReleasesOptions) error {
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
jiracli.GJsonQueryUsage(cmd, &opts.CommonOptions)
cmd.Flag("query", "filter the results using a literal string").Short('q').StringVar(&opts.Query)
cmd.Flag("status", "list of status values used to filter the results by version status").Short('s').StringsVar(&opts.Status)
cmd.Flag("order", "order the results by a field: description, name, releaseDate, sequence, startDate").StringVar(&opts.OrderBy)
cmd.Arg("PROJECT", "project id or key").Required().StringVar(&opts.Project)
return nil
}

func CmdReleases(o *oreo.Client, globals *jiracli.GlobalOptions, opts *ReleasesOptions) error {
data, err := jira.GetProjectVersionsPaginated(o, globals.Endpoint.Value, opts.Project, opts.Status, opts.Query, opts.OrderBy)
if err != nil {
return err
}
if err := opts.PrintTemplate(data); err != nil {
return err
}
return nil
}
174 changes: 174 additions & 0 deletions jiradata/PageOfVersion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
package jiradata

/////////////////////////////////////////////////////////////////////////
// This Code is Generated by SlipScheme Project:
// https://github.com/coryb/slipscheme
//
// Generated with command:
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/PageofVersion.json
/////////////////////////////////////////////////////////////////////////
// DO NOT EDIT //
/////////////////////////////////////////////////////////////////////////

// PageOfVersion defined from schema:
// {
// "title": "Page of Version",
// "id": "https://docs.atlassian.com/jira/REST/schema/page-of-version#",
// "type": "object",
// "properties": {
// "isLast": {
// "title": "isLast",
// "type": "boolean"
// },
// "maxResults": {
// "title": "maxResults",
// "type": "integer"
// },
// "nextPage": {
// "title": "nextPage",
// "type": "string"
// },
// "self": {
// "title": "self",
// "type": "string"
// },
// "startAt": {
// "title": "startAt",
// "type": "integer"
// },
// "total": {
// "title": "total",
// "type": "integer"
// },
// "values": {
// "title": "values",
// "type": "array",
// "items": {
// "title": "Version",
// "type": "object",
// "properties": {
// "archived": {
// "title": "archived",
// "type": "boolean"
// },
// "description": {
// "title": "description",
// "type": "string"
// },
// "expand": {
// "title": "expand",
// "type": "string"
// },
// "id": {
// "title": "id",
// "type": "string"
// },
// "moveUnfixedIssuesTo": {
// "title": "moveUnfixedIssuesTo",
// "type": "string"
// },
// "name": {
// "title": "name",
// "type": "string"
// },
// "operations": {
// "title": "operations",
// "type": "array",
// "items": {
// "title": "Simple Link",
// "type": "object",
// "properties": {
// "href": {
// "title": "href",
// "type": "string"
// },
// "iconClass": {
// "title": "iconClass",
// "type": "string"
// },
// "id": {
// "title": "id",
// "type": "string"
// },
// "label": {
// "title": "label",
// "type": "string"
// },
// "styleClass": {
// "title": "styleClass",
// "type": "string"
// },
// "title": {
// "title": "title",
// "type": "string"
// },
// "weight": {
// "title": "weight",
// "type": "integer"
// }
// }
// }
// },
// "overdue": {
// "title": "overdue",
// "type": "boolean"
// },
// "project": {
// "title": "project",
// "type": "string"
// },
// "projectId": {
// "title": "projectId",
// "type": "integer"
// },
// "released": {
// "title": "released",
// "type": "boolean"
// },
// "remotelinks": {
// "title": "remotelinks",
// "type": "array",
// "items": {
// "title": "Remote Entity Link",
// "type": "object",
// "properties": {
// "link": {
// "title": "link"
// },
// "name": {
// "title": "name",
// "type": "string"
// },
// "self": {
// "title": "self",
// "type": "string"
// }
// }
// }
// },
// "self": {
// "title": "self",
// "type": "string"
// },
// "userReleaseDate": {
// "title": "userReleaseDate",
// "type": "string"
// },
// "userStartDate": {
// "title": "userStartDate",
// "type": "string"
// }
// }
// }
// }
// }
// }
type PageOfVersion struct {
IsLast bool `json:"isLast,omitempty" yaml:"isLast,omitempty"`
MaxResults int `json:"maxResults,omitempty" yaml:"maxResults,omitempty"`
NextPage string `json:"nextPage,omitempty" yaml:"nextPage,omitempty"`
Self string `json:"self,omitempty" yaml:"self,omitempty"`
StartAt int `json:"startAt,omitempty" yaml:"startAt,omitempty"`
Total int `json:"total,omitempty" yaml:"total,omitempty"`
Values Values `json:"values,omitempty" yaml:"values,omitempty"`
}
2 changes: 1 addition & 1 deletion jiradata/RemoteEntityLink.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package jiradata
// https://github.com/coryb/slipscheme
//
// Generated with command:
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/Project.json
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/PageofVersion.json
/////////////////////////////////////////////////////////////////////////
// DO NOT EDIT //
/////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion jiradata/Remotelinks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package jiradata
// https://github.com/coryb/slipscheme
//
// Generated with command:
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/Project.json
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/PageofVersion.json
/////////////////////////////////////////////////////////////////////////
// DO NOT EDIT //
/////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion jiradata/SimpleLink.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package jiradata
// https://github.com/coryb/slipscheme
//
// Generated with command:
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/Project.json
// slipscheme -dir jiradata -pkg jiradata -overwrite schemas/PageofVersion.json
/////////////////////////////////////////////////////////////////////////
// DO NOT EDIT //
/////////////////////////////////////////////////////////////////////////
Expand Down
Loading