mirror of
https://github.com/Threnklyn/jira.git
synced 2026-06-07 21:43:32 +02:00
refactor trivial objects in favor of arguments to static functions
This commit is contained in:
+16
-13
@@ -2,16 +2,18 @@ package jiracli
|
||||
|
||||
import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type CreateMetaOptions struct {
|
||||
GlobalOptions
|
||||
Project string `yaml:"project,omitempty" json:"project,omitempty"`
|
||||
IssueType string `yaml:"issuetype,omitempty" json:"issuetype,omitempty"`
|
||||
GlobalOptions `yaml:",inline" figtree:",inline"`
|
||||
Project string `yaml:"project,omitempty" json:"project,omitempty"`
|
||||
IssueType string `yaml:"issuetype,omitempty" json:"issuetype,omitempty"`
|
||||
}
|
||||
|
||||
func (jc *JiraCli) CmdCreateMetaRegistry() *CommandRegistryEntry {
|
||||
func CmdCreateMetaRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
opts := CreateMetaOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
Template: figtree.NewStringOption("createmeta"),
|
||||
@@ -21,32 +23,33 @@ func (jc *JiraCli) CmdCreateMetaRegistry() *CommandRegistryEntry {
|
||||
return &CommandRegistryEntry{
|
||||
"View 'create' metadata",
|
||||
func() error {
|
||||
return jc.CmdCreateMeta(&opts)
|
||||
return CmdCreateMeta(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
return jc.CmdCreateMetaUsage(cmd, &opts)
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
return CmdCreateMetaUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (jc *JiraCli) CmdCreateMetaUsage(cmd *kingpin.CmdClause, opts *CreateMetaOptions) error {
|
||||
if err := jc.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
func CmdCreateMetaUsage(cmd *kingpin.CmdClause, opts *CreateMetaOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jc.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Flag("project", "project to fetch create metadata").Short('p').StringVar(&opts.Project)
|
||||
cmd.Flag("issuetype", "issuetype in project to fetch create metadata").Short('i').StringVar(&opts.IssueType)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Create will get issue create metadata and send to "createmeta" template
|
||||
func (jc *JiraCli) CmdCreateMeta(opts *CreateMetaOptions) error {
|
||||
if err := jc.defaultIssueType(&opts.Project, &opts.IssueType); err != nil {
|
||||
func CmdCreateMeta(o *oreo.Client, opts *CreateMetaOptions) error {
|
||||
if err := defaultIssueType(o, opts.Endpoint.Value, &opts.Project, &opts.IssueType); err != nil {
|
||||
return err
|
||||
}
|
||||
createMeta, err := jc.GetIssueCreateMetaIssueType(opts.Project, opts.IssueType)
|
||||
createMeta, err := jira.GetIssueCreateMetaIssueType(o, opts.Endpoint.Value, opts.Project, opts.IssueType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return jc.runTemplate(opts.Template.Value, createMeta, nil)
|
||||
return runTemplate(opts.Template.Value, createMeta, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user