mirror of
https://github.com/Threnklyn/jira.git
synced 2026-06-07 13:33:32 +02:00
refactor trivial objects in favor of arguments to static functions
This commit is contained in:
+18
-13
@@ -3,41 +3,46 @@ package jiracli
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type LabelsRemoveOptions struct {
|
||||
GlobalOptions
|
||||
Issue string
|
||||
Labels []string
|
||||
GlobalOptions `yaml:",inline" figtree:",inline"`
|
||||
Issue string
|
||||
Labels []string
|
||||
}
|
||||
|
||||
func (jc *JiraCli) CmdLabelsRemoveRegistry() *CommandRegistryEntry {
|
||||
func CmdLabelsRemoveRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
opts := LabelsRemoveOptions{}
|
||||
return &CommandRegistryEntry{
|
||||
"Remove labels from an issue",
|
||||
func() error {
|
||||
return jc.CmdLabelsRemove(&opts)
|
||||
return CmdLabelsRemove(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
return jc.CmdLabelsRemoveUsage(cmd, &opts)
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
return CmdLabelsRemoveUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (jc *JiraCli) CmdLabelsRemoveUsage(cmd *kingpin.CmdClause, opts *LabelsRemoveOptions) error {
|
||||
if err := jc.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
func CmdLabelsRemoveUsage(cmd *kingpin.CmdClause, opts *LabelsRemoveOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jc.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Arg("ISSUE", "issue id to modify labels").Required().StringVar(&opts.Issue)
|
||||
cmd.Arg("LABEL", "label to remove from issue").Required().StringsVar(&opts.Labels)
|
||||
return nil
|
||||
}
|
||||
|
||||
// CmdLabels will remove labels on a given issue
|
||||
func (jc *JiraCli) CmdLabelsRemove(opts *LabelsRemoveOptions) error {
|
||||
func CmdLabelsRemove(o *oreo.Client, opts *LabelsRemoveOptions) error {
|
||||
ops := jiradata.FieldOperations{}
|
||||
for _, label := range opts.Labels {
|
||||
ops = append(ops, jiradata.FieldOperation{
|
||||
@@ -50,13 +55,13 @@ func (jc *JiraCli) CmdLabelsRemove(opts *LabelsRemoveOptions) error {
|
||||
},
|
||||
}
|
||||
|
||||
err := jc.EditIssue(opts.Issue, &issueUpdate)
|
||||
err := jira.EditIssue(o, opts.Endpoint.Value, opts.Issue, &issueUpdate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, jc.Endpoint, opts.Issue)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, opts.Endpoint.Value, opts.Issue)
|
||||
if opts.Browse.Value {
|
||||
return jc.CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user