mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-19 04:33:28 +02:00
ba7cc13145
There should be no reason to use gopkg.in versioned imports now that we're using go modules. I think, IANAE. gopkg.in kind of gets in the way of modules, as it only pulls over tagged releases from github.com -- this then means that you need to use go modules 'replace' syntax in the go.mod to use a non-versioned commit or branch. This is feasible, but kind of ugly. go modules defaults to pulling the latest version, so the default behavior is the same as when pulling go-jira.v1 from gopkg.in.
74 lines
2.1 KiB
Go
74 lines
2.1 KiB
Go
package jiracmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/coryb/figtree"
|
|
"github.com/coryb/oreo"
|
|
|
|
"github.com/go-jira/jira"
|
|
"github.com/go-jira/jira/jiracli"
|
|
"github.com/go-jira/jira/jiradata"
|
|
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
|
)
|
|
|
|
type RankOptions struct {
|
|
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
|
First string `yaml:"first,omitempty" json:"first,omitempty"`
|
|
Second string `yaml:"second,omitempty" json:"second,omitempty"`
|
|
Order string `yaml:"order,omitempty" json:"order,omitempty"`
|
|
}
|
|
|
|
func CmdRankRegistry() *jiracli.CommandRegistryEntry {
|
|
opts := RankOptions{}
|
|
|
|
return &jiracli.CommandRegistryEntry{
|
|
"Mark issues as blocker",
|
|
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
|
jiracli.LoadConfigs(cmd, fig, &opts)
|
|
return CmdRankUsage(cmd, &opts)
|
|
},
|
|
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
|
|
return CmdRank(o, globals, &opts)
|
|
},
|
|
}
|
|
}
|
|
|
|
func CmdRankUsage(cmd *kingpin.CmdClause, opts *RankOptions) error {
|
|
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
|
cmd.Arg("FIRST-ISSUE", "first issue").Required().StringVar(&opts.First)
|
|
cmd.Arg("after|before", "rank ordering").Required().HintOptions("after", "before").EnumVar(&opts.Order, "after", "before")
|
|
cmd.Arg("SECOND-ISSUE", "second issue").Required().StringVar(&opts.Second)
|
|
return nil
|
|
}
|
|
|
|
// CmdRank order two issue
|
|
func CmdRank(o *oreo.Client, globals *jiracli.GlobalOptions, opts *RankOptions) error {
|
|
req := &jiradata.RankRequest{
|
|
Issues: []string{opts.First},
|
|
}
|
|
|
|
if opts.Order == "after" {
|
|
req.RankAfterIssue = opts.Second
|
|
} else {
|
|
req.RankBeforeIssue = opts.Second
|
|
}
|
|
|
|
if err := jira.RankIssues(o, globals.Endpoint.Value, req); err != nil {
|
|
return err
|
|
}
|
|
|
|
if !globals.Quiet.Value {
|
|
fmt.Printf("OK %s %s\n", opts.First, jira.URLJoin(globals.Endpoint.Value, "browse", opts.First))
|
|
fmt.Printf("OK %s %s\n", opts.Second, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Second))
|
|
}
|
|
|
|
if opts.Browse.Value {
|
|
if err := CmdBrowse(globals, opts.First); err != nil {
|
|
return CmdBrowse(globals, opts.Second)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|