mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-18 20:23:28 +02:00
refactor for GlobalOptions and CommonOptions
This commit is contained in:
+48
-47
@@ -15,6 +15,7 @@ import (
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracmd"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
"gopkg.in/op/go-logging.v1"
|
||||
)
|
||||
@@ -100,200 +101,200 @@ func main() {
|
||||
registry := []jiracli.CommandRegistry{
|
||||
jiracli.CommandRegistry{
|
||||
Command: "login",
|
||||
Entry: jiracli.CmdLoginRegistry(fig, o),
|
||||
Entry: jiracmd.CmdLoginRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "logout",
|
||||
Entry: jiracli.CmdLogoutRegistry(fig, o),
|
||||
Entry: jiracmd.CmdLogoutRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Entry: jiracli.CmdListRegistry(fig, o),
|
||||
Entry: jiracmd.CmdListRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "view",
|
||||
Entry: jiracli.CmdViewRegistry(fig, o),
|
||||
Entry: jiracmd.CmdViewRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "create",
|
||||
Entry: jiracli.CmdCreateRegistry(fig, o),
|
||||
Entry: jiracmd.CmdCreateRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "edit",
|
||||
Entry: jiracli.CmdEditRegistry(fig, o),
|
||||
Entry: jiracmd.CmdEditRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "comment",
|
||||
Entry: jiracli.CmdCommentRegistry(fig, o),
|
||||
Entry: jiracmd.CmdCommentRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "worklog list",
|
||||
Entry: jiracli.CmdWorklogListRegistry(fig, o),
|
||||
Entry: jiracmd.CmdWorklogListRegistry(o),
|
||||
Default: true,
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "worklog add",
|
||||
Entry: jiracli.CmdWorklogAddRegistry(fig, o),
|
||||
Entry: jiracmd.CmdWorklogAddRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "fields",
|
||||
Entry: jiracli.CmdFieldsRegistry(fig, o),
|
||||
Entry: jiracmd.CmdFieldsRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "createmeta",
|
||||
Entry: jiracli.CmdCreateMetaRegistry(fig, o),
|
||||
Entry: jiracmd.CmdCreateMetaRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "editmeta",
|
||||
Entry: jiracli.CmdEditMetaRegistry(fig, o),
|
||||
Entry: jiracmd.CmdEditMetaRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "subtask",
|
||||
Entry: jiracli.CmdSubtaskRegistry(fig, o),
|
||||
Entry: jiracmd.CmdSubtaskRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "dup",
|
||||
Entry: jiracli.CmdDupRegistry(fig, o),
|
||||
Entry: jiracmd.CmdDupRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "block",
|
||||
Entry: jiracli.CmdBlockRegistry(fig, o),
|
||||
Entry: jiracmd.CmdBlockRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "issuelink",
|
||||
Entry: jiracli.CmdIssueLinkRegistry(fig, o),
|
||||
Entry: jiracmd.CmdIssueLinkRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "issuelinktypes",
|
||||
Entry: jiracli.CmdIssueLinkTypesRegistry(fig, o),
|
||||
Entry: jiracmd.CmdIssueLinkTypesRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "transition",
|
||||
Aliases: []string{"trans"},
|
||||
Entry: jiracli.CmdTransitionRegistry(fig, o, ""),
|
||||
Entry: jiracmd.CmdTransitionRegistry(o, ""),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "transitions",
|
||||
Entry: jiracli.CmdTransitionsRegistry(fig, o, "transitions"),
|
||||
Entry: jiracmd.CmdTransitionsRegistry(o, "transitions"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "transmeta",
|
||||
Entry: jiracli.CmdTransitionsRegistry(fig, o, "debug"),
|
||||
Entry: jiracmd.CmdTransitionsRegistry(o, "debug"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "close",
|
||||
Entry: jiracli.CmdTransitionRegistry(fig, o, "close"),
|
||||
Entry: jiracmd.CmdTransitionRegistry(o, "close"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "acknowledge",
|
||||
Aliases: []string{"ack"},
|
||||
Entry: jiracli.CmdTransitionRegistry(fig, o, "acknowledge"),
|
||||
Entry: jiracmd.CmdTransitionRegistry(o, "acknowledge"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "reopen",
|
||||
Entry: jiracli.CmdTransitionRegistry(fig, o, "reopen"),
|
||||
Entry: jiracmd.CmdTransitionRegistry(o, "reopen"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "resolve",
|
||||
Entry: jiracli.CmdTransitionRegistry(fig, o, "resolve"),
|
||||
Entry: jiracmd.CmdTransitionRegistry(o, "resolve"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "start",
|
||||
Entry: jiracli.CmdTransitionRegistry(fig, o, "start"),
|
||||
Entry: jiracmd.CmdTransitionRegistry(o, "start"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "stop",
|
||||
Entry: jiracli.CmdTransitionRegistry(fig, o, "stop"),
|
||||
Entry: jiracmd.CmdTransitionRegistry(o, "stop"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "todo",
|
||||
Entry: jiracli.CmdTransitionRegistry(fig, o, "To Do"),
|
||||
Entry: jiracmd.CmdTransitionRegistry(o, "To Do"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "backlog",
|
||||
Entry: jiracli.CmdTransitionRegistry(fig, o, "Backlog"),
|
||||
Entry: jiracmd.CmdTransitionRegistry(o, "Backlog"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "done",
|
||||
Entry: jiracli.CmdTransitionRegistry(fig, o, "Done"),
|
||||
Entry: jiracmd.CmdTransitionRegistry(o, "Done"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "in-progress",
|
||||
Aliases: []string{"prog", "progress"},
|
||||
Entry: jiracli.CmdTransitionRegistry(fig, o, "Progress"),
|
||||
Entry: jiracmd.CmdTransitionRegistry(o, "Progress"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "vote",
|
||||
Entry: jiracli.CmdVoteRegistry(fig, o),
|
||||
Entry: jiracmd.CmdVoteRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "rank",
|
||||
Entry: jiracli.CmdRankRegistry(fig, o),
|
||||
Entry: jiracmd.CmdRankRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "watch",
|
||||
Entry: jiracli.CmdWatchRegistry(fig, o),
|
||||
Entry: jiracmd.CmdWatchRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "labels add",
|
||||
Entry: jiracli.CmdLabelsAddRegistry(fig, o),
|
||||
Entry: jiracmd.CmdLabelsAddRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "labels set",
|
||||
Entry: jiracli.CmdLabelsAddRegistry(fig, o),
|
||||
Entry: jiracmd.CmdLabelsAddRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "labels remove",
|
||||
Entry: jiracli.CmdLabelsAddRegistry(fig, o),
|
||||
Entry: jiracmd.CmdLabelsAddRegistry(o),
|
||||
Aliases: []string{"rm"},
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "take",
|
||||
Entry: jiracli.CmdTakeRegistry(fig, o),
|
||||
Entry: jiracmd.CmdTakeRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "assign",
|
||||
Entry: jiracli.CmdAssignRegistry(fig, o),
|
||||
Entry: jiracmd.CmdAssignRegistry(o),
|
||||
Aliases: []string{"give"},
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "unassign",
|
||||
Entry: jiracli.CmdUnassignRegistry(fig, o),
|
||||
Entry: jiracmd.CmdUnassignRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "component add",
|
||||
Entry: jiracli.CmdComponentAddRegistry(fig, o),
|
||||
Entry: jiracmd.CmdComponentAddRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "components",
|
||||
Entry: jiracli.CmdComponentsRegistry(fig, o),
|
||||
Entry: jiracmd.CmdComponentsRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "issuetypes",
|
||||
Entry: jiracli.CmdIssueTypesRegistry(fig, o),
|
||||
Entry: jiracmd.CmdIssueTypesRegistry(o),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "export-templates",
|
||||
Entry: jiracli.CmdExportTemplatesRegistry(fig),
|
||||
Entry: jiracmd.CmdExportTemplatesRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "unexport-templates",
|
||||
Entry: jiracli.CmdUnexportTemplatesRegistry(fig),
|
||||
Entry: jiracmd.CmdUnexportTemplatesRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "browse",
|
||||
Entry: jiracli.CmdBrowseRegistry(fig),
|
||||
Entry: jiracmd.CmdBrowseRegistry(),
|
||||
Aliases: []string{"b"},
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "request",
|
||||
Entry: jiracli.CmdRequestRegistry(fig, o),
|
||||
Entry: jiracmd.CmdRequestRegistry(o),
|
||||
Aliases: []string{"req"},
|
||||
},
|
||||
}
|
||||
|
||||
jiracli.Register(app, registry)
|
||||
jiracli.Register(app, fig, registry)
|
||||
|
||||
// register custom commands
|
||||
data := struct {
|
||||
|
||||
+24
-25
@@ -26,19 +26,22 @@ type Exit struct {
|
||||
}
|
||||
|
||||
type GlobalOptions struct {
|
||||
Endpoint figtree.StringOption `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
|
||||
User figtree.StringOption `json:"user,omitempty" yaml:"user,omitempty"`
|
||||
PasswordSource figtree.StringOption `json:"password-source,omitempty" yaml:"password-source,omitempty"`
|
||||
}
|
||||
|
||||
type CommonOptions struct {
|
||||
Browse figtree.BoolOption `json:"browse,omitempty" yaml:"browse,omitempty"`
|
||||
Editor figtree.StringOption `json:"editor,omitempty" yaml:"editor,omitempty"`
|
||||
Endpoint figtree.StringOption `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
|
||||
SkipEditing figtree.BoolOption `json:"noedit,omitempty" yaml:"noedit,omitempty"`
|
||||
PasswordSource figtree.StringOption `json:"password-source,omitempty" yaml:"password-source,omitempty"`
|
||||
Template figtree.StringOption `json:"template,omitempty" yaml:"template,omitempty"`
|
||||
User figtree.StringOption `json:"user,omitempty" yaml:"user,omitempty"`
|
||||
}
|
||||
|
||||
type CommandRegistryEntry struct {
|
||||
Help string
|
||||
ExecuteFunc func() error
|
||||
UsageFunc func(*kingpin.CmdClause) error
|
||||
UsageFunc func(*figtree.FigTree, *kingpin.CmdClause) error
|
||||
ExecuteFunc func(*GlobalOptions) error
|
||||
}
|
||||
|
||||
type CommandRegistry struct {
|
||||
@@ -54,7 +57,13 @@ type kingpinAppOrCommand interface {
|
||||
GetCommand(string) *kingpin.CmdClause
|
||||
}
|
||||
|
||||
func Register(app *kingpin.Application, reg []CommandRegistry) {
|
||||
func Register(app *kingpin.Application, fig *figtree.FigTree, reg []CommandRegistry) {
|
||||
globals := GlobalOptions{
|
||||
User: figtree.NewStringOption(os.Getenv("USER")),
|
||||
}
|
||||
app.Flag("endpoint", "Base URI to use for Jira").Short('e').SetValue(&globals.Endpoint)
|
||||
app.Flag("user", "Login name used for authentication with Jira service").Short('u').SetValue(&globals.User)
|
||||
|
||||
for _, command := range reg {
|
||||
copy := command
|
||||
commandFields := strings.Fields(copy.Command)
|
||||
@@ -70,6 +79,8 @@ func Register(app *kingpin.Application, reg []CommandRegistry) {
|
||||
}
|
||||
|
||||
cmd := appOrCmd.Command(commandFields[len(commandFields)-1], copy.Entry.Help)
|
||||
LoadConfigs(cmd, fig, &globals)
|
||||
|
||||
for _, alias := range copy.Aliases {
|
||||
cmd = cmd.Alias(alias)
|
||||
}
|
||||
@@ -77,29 +88,17 @@ func Register(app *kingpin.Application, reg []CommandRegistry) {
|
||||
cmd = cmd.Default()
|
||||
}
|
||||
if copy.Entry.UsageFunc != nil {
|
||||
copy.Entry.UsageFunc(cmd)
|
||||
copy.Entry.UsageFunc(fig, cmd)
|
||||
}
|
||||
|
||||
cmd.Action(
|
||||
func(_ *kingpin.ParseContext) error {
|
||||
return copy.Entry.ExecuteFunc()
|
||||
return copy.Entry.ExecuteFunc(&globals)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func GlobalUsage(cmd *kingpin.CmdClause, opts *GlobalOptions) error {
|
||||
cmd.PreAction(func(_ *kingpin.ParseContext) error {
|
||||
if opts.User.Value == "" {
|
||||
opts.User = figtree.NewStringOption(os.Getenv("USER"))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
cmd.Flag("endpoint", "Base URI to use for Jira").Short('e').SetValue(&opts.Endpoint)
|
||||
cmd.Flag("user", "Login name used for authentication with Jira service").Short('u').SetValue(&opts.User)
|
||||
return nil
|
||||
}
|
||||
|
||||
func LoadConfigs(cmd *kingpin.CmdClause, fig *figtree.FigTree, opts interface{}) {
|
||||
cmd.PreAction(func(_ *kingpin.ParseContext) error {
|
||||
os.Setenv("JIRA_OPERATION", cmd.FullCommand())
|
||||
@@ -112,19 +111,19 @@ func LoadConfigs(cmd *kingpin.CmdClause, fig *figtree.FigTree, opts interface{})
|
||||
})
|
||||
}
|
||||
|
||||
func BrowseUsage(cmd *kingpin.CmdClause, opts *GlobalOptions) {
|
||||
func BrowseUsage(cmd *kingpin.CmdClause, opts *CommonOptions) {
|
||||
cmd.Flag("browse", "Open issue(s) in browser after operation").Short('b').SetValue(&opts.Browse)
|
||||
}
|
||||
|
||||
func EditorUsage(cmd *kingpin.CmdClause, opts *GlobalOptions) {
|
||||
func EditorUsage(cmd *kingpin.CmdClause, opts *CommonOptions) {
|
||||
cmd.Flag("editor", "Editor to use").SetValue(&opts.Editor)
|
||||
}
|
||||
|
||||
func TemplateUsage(cmd *kingpin.CmdClause, opts *GlobalOptions) {
|
||||
func TemplateUsage(cmd *kingpin.CmdClause, opts *CommonOptions) {
|
||||
cmd.Flag("template", "Template to use for output").Short('t').SetValue(&opts.Template)
|
||||
}
|
||||
|
||||
func (o *GlobalOptions) editFile(fileName string) (changes bool, err error) {
|
||||
func (o *CommonOptions) editFile(fileName string) (changes bool, err error) {
|
||||
var editor string
|
||||
for _, ed := range []string{o.Editor.Value, os.Getenv("JIRA_EDITOR"), os.Getenv("EDITOR"), "vim"} {
|
||||
if ed != "" {
|
||||
@@ -187,7 +186,7 @@ func (o *GlobalOptions) editFile(fileName string) (changes bool, err error) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
func EditLoop(opts *GlobalOptions, input interface{}, output interface{}, submit func() error) error {
|
||||
func EditLoop(opts *CommonOptions, input interface{}, output interface{}, submit func() error) error {
|
||||
tmpFile, err := tmpTemplate(opts.Template.Value, input)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
+11
-15
@@ -5,38 +5,34 @@ import (
|
||||
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type AssignOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
Assignee string `yaml:"assignee,omitempty" json:"assignee,omitempty"`
|
||||
}
|
||||
|
||||
func CmdAssignRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdAssignRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := AssignOptions{}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Assign user to issue",
|
||||
func() error {
|
||||
return CmdAssign(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdAssignUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdAssign(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdAssignUsage(cmd *kingpin.CmdClause, opts *AssignOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("default", "use default user for assignee").PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
if jiracli.FlagValue(ctx, "default") == "true" {
|
||||
opts.Assignee = "-1"
|
||||
@@ -49,16 +45,16 @@ func CmdAssignUsage(cmd *kingpin.CmdClause, opts *AssignOptions) error {
|
||||
}
|
||||
|
||||
// CmdAssign will assign an issue to a user
|
||||
func CmdAssign(o *oreo.Client, opts *AssignOptions) error {
|
||||
err := jira.IssueAssign(o, opts.Endpoint.Value, opts.Issue, opts.Assignee)
|
||||
func CmdAssign(o *oreo.Client, globals *jiracli.GlobalOptions, opts *AssignOptions) error {
|
||||
err := jira.IssueAssign(o, globals.Endpoint.Value, opts.Issue, opts.Assignee)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, opts.Endpoint.Value, opts.Issue)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
||||
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
+16
-19
@@ -13,13 +13,13 @@ import (
|
||||
)
|
||||
|
||||
type BlockOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiradata.LinkIssueRequest `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
}
|
||||
|
||||
func CmdBlockRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdBlockRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := BlockOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("edit"),
|
||||
},
|
||||
LinkIssueRequest: jiradata.LinkIssueRequest{
|
||||
@@ -33,23 +33,20 @@ func CmdBlockRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegi
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Mark issues as blocker",
|
||||
func() error {
|
||||
return CmdBlock(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdBlockUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdBlock(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdBlockUsage(cmd *kingpin.CmdClause, opts *BlockOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("comment", "Comment message when marking issue as blocker").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Comment = &jiradata.Comment{
|
||||
Body: jiracli.FlagValue(ctx, "comment"),
|
||||
@@ -63,17 +60,17 @@ func CmdBlockUsage(cmd *kingpin.CmdClause, opts *BlockOptions) error {
|
||||
|
||||
// CmdBlock will update the given issue as being a duplicate by the given dup issue
|
||||
// and will attempt to resolve the dup issue
|
||||
func CmdBlock(o *oreo.Client, opts *BlockOptions) error {
|
||||
if err := jira.LinkIssues(o, opts.Endpoint.Value, &opts.LinkIssueRequest); err != nil {
|
||||
func CmdBlock(o *oreo.Client, globals *jiracli.GlobalOptions, opts *BlockOptions) error {
|
||||
if err := jira.LinkIssues(o, globals.Endpoint.Value, &opts.LinkIssueRequest); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.InwardIssue.Key, opts.Endpoint.Value, opts.InwardIssue.Key)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.OutwardIssue.Key, opts.Endpoint.Value, opts.OutwardIssue.Key)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.InwardIssue.Key, globals.Endpoint.Value, opts.InwardIssue.Key)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.OutwardIssue.Key, globals.Endpoint.Value, opts.OutwardIssue.Key)
|
||||
|
||||
if opts.Browse.Value {
|
||||
if err := CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.InwardIssue.Key}); err != nil {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.OutwardIssue.Key})
|
||||
if err := CmdBrowse(globals, opts.InwardIssue.Key); err != nil {
|
||||
return CmdBrowse(globals, opts.OutwardIssue.Key)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-25
@@ -9,36 +9,22 @@ import (
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type BrowseOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdBrowseRegistry(fig *figtree.FigTree) *jiracli.CommandRegistryEntry {
|
||||
opts := BrowseOptions{}
|
||||
func CmdBrowseRegistry() *jiracli.CommandRegistryEntry {
|
||||
issue := ""
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Open issue in browser",
|
||||
func() error {
|
||||
return CmdBrowse(&opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdBrowseUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdBrowseUsage(cmd *kingpin.CmdClause, opts *BrowseOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
cmd.Arg("ISSUE", "Issue to browse to").Required().StringVar(&opts.Issue)
|
||||
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
cmd.Arg("ISSUE", "Issue to browse to").Required().StringVar(&issue)
|
||||
return nil
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdBrowse(globals, issue)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// CmdBrowse open the default system browser to the provided issue
|
||||
func CmdBrowse(opts *BrowseOptions) error {
|
||||
return browser.OpenURL(fmt.Sprintf("%s/browse/%s", opts.Endpoint.Value, opts.Issue))
|
||||
func CmdBrowse(globals *jiracli.GlobalOptions, issue string) error {
|
||||
return browser.OpenURL(fmt.Sprintf("%s/browse/%s", globals.Endpoint.Value, issue))
|
||||
}
|
||||
|
||||
+15
-18
@@ -13,14 +13,14 @@ import (
|
||||
)
|
||||
|
||||
type CommentOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdCommentRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdCommentRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := CommentOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("comment"),
|
||||
},
|
||||
Overrides: map[string]string{},
|
||||
@@ -28,23 +28,20 @@ func CmdCommentRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRe
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Add comment to issue",
|
||||
func() error {
|
||||
return CmdComment(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdCommentUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdComment(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdCommentUsage(cmd *kingpin.CmdClause, opts *CommentOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("comment", "Comment message for issue").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Overrides["comment"] = jiracli.FlagValue(ctx, "comment")
|
||||
return nil
|
||||
@@ -54,25 +51,25 @@ func CmdCommentUsage(cmd *kingpin.CmdClause, opts *CommentOptions) error {
|
||||
}
|
||||
|
||||
// CmdComment will update issue with comment
|
||||
func CmdComment(o *oreo.Client, opts *CommentOptions) error {
|
||||
func CmdComment(o *oreo.Client, globals *jiracli.GlobalOptions, opts *CommentOptions) error {
|
||||
comment := jiradata.Comment{}
|
||||
input := struct {
|
||||
Overrides map[string]string
|
||||
}{
|
||||
opts.Overrides,
|
||||
}
|
||||
err := jiracli.EditLoop(&opts.GlobalOptions, &input, &comment, func() error {
|
||||
_, err := jira.IssueAddComment(o, opts.Endpoint.Value, opts.Issue, &comment)
|
||||
err := jiracli.EditLoop(&opts.CommonOptions, &input, &comment, func() error {
|
||||
_, err := jira.IssueAddComment(o, globals.Endpoint.Value, opts.Issue, &comment)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, opts.Endpoint.Value, opts.Issue)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
||||
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
+12
-15
@@ -13,35 +13,32 @@ import (
|
||||
)
|
||||
|
||||
type ComponentAddOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiradata.Component `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
}
|
||||
|
||||
func CmdComponentAddRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdComponentAddRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := ComponentAddOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("component-add"),
|
||||
},
|
||||
}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Add component",
|
||||
func() error {
|
||||
return CmdComponentAdd(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdComponentAddUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdComponentAdd(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdComponentAddUsage(cmd *kingpin.CmdClause, opts *ComponentAddOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("noedit", "Disable opening the editor").SetValue(&opts.SkipEditing)
|
||||
cmd.Flag("project", "project to create component in").Short('p').StringVar(&opts.Project)
|
||||
cmd.Flag("name", "name of component").Short('n').StringVar(&opts.Name)
|
||||
@@ -52,12 +49,12 @@ func CmdComponentAddUsage(cmd *kingpin.CmdClause, opts *ComponentAddOptions) err
|
||||
|
||||
// CmdComponentAdd sends the provided overrides to the "component-add" template for editing, then
|
||||
// will parse the edited document as YAML and submit the document to jira.
|
||||
func CmdComponentAdd(o *oreo.Client, opts *ComponentAddOptions) error {
|
||||
func CmdComponentAdd(o *oreo.Client, globals *jiracli.GlobalOptions, opts *ComponentAddOptions) error {
|
||||
var err error
|
||||
component := &jiradata.Component{}
|
||||
var resp *jiradata.Component
|
||||
err = jiracli.EditLoop(&opts.GlobalOptions, &opts.Component, component, func() error {
|
||||
resp, err = jira.CreateComponent(o, opts.Endpoint.Value, component)
|
||||
err = jiracli.EditLoop(&opts.CommonOptions, &opts.Component, component, func() error {
|
||||
resp, err = jira.CreateComponent(o, globals.Endpoint.Value, component)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
+10
-13
@@ -12,45 +12,42 @@ import (
|
||||
)
|
||||
|
||||
type ComponentsOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Project string `yaml:"project,omitempty" json:"project,omitempty"`
|
||||
}
|
||||
|
||||
func CmdComponentsRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdComponentsRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := ComponentsOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("components"),
|
||||
},
|
||||
}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Show components for a project",
|
||||
func() error {
|
||||
return CmdComponents(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdComponentsUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdComponents(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdComponentsUsage(cmd *kingpin.CmdClause, opts *ComponentsOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("project", "project to list components").Short('p').StringVar(&opts.Project)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CmdComponents will get available components for project and send to the "components" template
|
||||
func CmdComponents(o *oreo.Client, opts *ComponentsOptions) error {
|
||||
func CmdComponents(o *oreo.Client, globals *jiracli.GlobalOptions, opts *ComponentsOptions) error {
|
||||
if opts.Project == "" {
|
||||
return fmt.Errorf("Project Required.")
|
||||
}
|
||||
data, err := jira.GetProjectComponents(o, opts.Endpoint.Value, opts.Project)
|
||||
data, err := jira.GetProjectComponents(o, globals.Endpoint.Value, opts.Project)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+19
-22
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
type CreateOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiradata.IssueUpdate `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Project string `yaml:"project,omitempty" json:"project,omitempty"`
|
||||
IssueType string `yaml:"issuetype,omitempty" json:"issuetype,omitempty"`
|
||||
@@ -23,9 +23,9 @@ type CreateOptions struct {
|
||||
SaveFile string `yaml:"savefile,omitempty" json:"savefile,omitempty"`
|
||||
}
|
||||
|
||||
func CmdCreateRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdCreateRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := CreateOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("create"),
|
||||
},
|
||||
Overrides: map[string]string{},
|
||||
@@ -33,23 +33,20 @@ func CmdCreateRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandReg
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Create issue",
|
||||
func() error {
|
||||
return CmdCreate(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdCreateUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdCreate(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdCreateUsage(cmd *kingpin.CmdClause, opts *CreateOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("noedit", "Disable opening the editor").SetValue(&opts.SkipEditing)
|
||||
cmd.Flag("project", "project to create issue in").Short('p').StringVar(&opts.Project)
|
||||
cmd.Flag("issuetype", "issuetype in to create").Short('i').StringVar(&opts.IssueType)
|
||||
@@ -64,16 +61,16 @@ func CmdCreateUsage(cmd *kingpin.CmdClause, opts *CreateOptions) error {
|
||||
|
||||
// CmdCreate sends the create-metadata to the "create" template for editing, then
|
||||
// will parse the edited document as YAML and submit the document to jira.
|
||||
func CmdCreate(o *oreo.Client, opts *CreateOptions) error {
|
||||
func CmdCreate(o *oreo.Client, globals *jiracli.GlobalOptions, opts *CreateOptions) error {
|
||||
type templateInput struct {
|
||||
Meta *jiradata.IssueType `yaml:"meta" json:"meta"`
|
||||
Overrides map[string]string `yaml:"overrides" json:"overrides"`
|
||||
}
|
||||
|
||||
if err := defaultIssueType(o, opts.Endpoint.Value, &opts.Project, &opts.IssueType); err != nil {
|
||||
if err := defaultIssueType(o, globals.Endpoint.Value, &opts.Project, &opts.IssueType); err != nil {
|
||||
return err
|
||||
}
|
||||
createMeta, err := jira.GetIssueCreateMetaIssueType(o, opts.Endpoint.Value, opts.Project, opts.IssueType)
|
||||
createMeta, err := jira.GetIssueCreateMetaIssueType(o, globals.Endpoint.Value, opts.Project, opts.IssueType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -85,18 +82,18 @@ func CmdCreate(o *oreo.Client, opts *CreateOptions) error {
|
||||
}
|
||||
input.Overrides["project"] = opts.Project
|
||||
input.Overrides["issuetype"] = opts.IssueType
|
||||
input.Overrides["user"] = opts.User.Value
|
||||
input.Overrides["user"] = globals.User.Value
|
||||
|
||||
var issueResp *jiradata.IssueCreateResponse
|
||||
err = jiracli.EditLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
issueResp, err = jira.CreateIssue(o, opts.Endpoint.Value, &issueUpdate)
|
||||
err = jiracli.EditLoop(&opts.CommonOptions, &input, &issueUpdate, func() error {
|
||||
issueResp, err = jira.CreateIssue(o, globals.Endpoint.Value, &issueUpdate)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("OK %s %s/browse/%s\n", issueResp.Key, opts.Endpoint.Value, issueResp.Key)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", issueResp.Key, globals.Endpoint.Value, issueResp.Key)
|
||||
|
||||
if opts.SaveFile != "" {
|
||||
fh, err := os.Create(opts.SaveFile)
|
||||
@@ -106,7 +103,7 @@ func CmdCreate(o *oreo.Client, opts *CreateOptions) error {
|
||||
defer fh.Close()
|
||||
out, err := yaml.Marshal(map[string]string{
|
||||
"issue": issueResp.Key,
|
||||
"link": fmt.Sprintf("%s/browse/%s", opts.Endpoint.Value, issueResp.Key),
|
||||
"link": fmt.Sprintf("%s/browse/%s", globals.Endpoint.Value, issueResp.Key),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -115,7 +112,7 @@ func CmdCreate(o *oreo.Client, opts *CreateOptions) error {
|
||||
}
|
||||
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, issueResp.Key})
|
||||
return CmdBrowse(globals, issueResp.Key)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+11
-14
@@ -9,46 +9,43 @@ import (
|
||||
)
|
||||
|
||||
type CreateMetaOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Project string `yaml:"project,omitempty" json:"project,omitempty"`
|
||||
IssueType string `yaml:"issuetype,omitempty" json:"issuetype,omitempty"`
|
||||
}
|
||||
|
||||
func CmdCreateMetaRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdCreateMetaRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := CreateMetaOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("createmeta"),
|
||||
},
|
||||
}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"View 'create' metadata",
|
||||
func() error {
|
||||
return CmdCreateMeta(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdCreateMetaUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdCreateMeta(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdCreateMetaUsage(cmd *kingpin.CmdClause, opts *CreateMetaOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
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 CmdCreateMeta(o *oreo.Client, opts *CreateMetaOptions) error {
|
||||
if err := defaultIssueType(o, opts.Endpoint.Value, &opts.Project, &opts.IssueType); err != nil {
|
||||
func CmdCreateMeta(o *oreo.Client, globals *jiracli.GlobalOptions, opts *CreateMetaOptions) error {
|
||||
if err := defaultIssueType(o, globals.Endpoint.Value, &opts.Project, &opts.IssueType); err != nil {
|
||||
return err
|
||||
}
|
||||
createMeta, err := jira.GetIssueCreateMetaIssueType(o, opts.Endpoint.Value, opts.Project, opts.IssueType)
|
||||
createMeta, err := jira.GetIssueCreateMetaIssueType(o, globals.Endpoint.Value, opts.Project, opts.IssueType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+18
-21
@@ -13,15 +13,15 @@ import (
|
||||
)
|
||||
|
||||
type DupOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiradata.LinkIssueRequest `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Duplicate string `yaml:"duplicate,omitempty" json:"duplicate,omitempty"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdDupRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdDupRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := DupOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("edit"),
|
||||
},
|
||||
LinkIssueRequest: jiradata.LinkIssueRequest{
|
||||
@@ -35,23 +35,20 @@ func CmdDupRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegist
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Mark issues as duplicate",
|
||||
func() error {
|
||||
return CmdDup(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdDupUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdDup(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdDupUsage(cmd *kingpin.CmdClause, opts *DupOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("comment", "Comment message when marking issue as duplicate").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Comment = &jiradata.Comment{
|
||||
Body: jiracli.FlagValue(ctx, "comment"),
|
||||
@@ -65,13 +62,13 @@ func CmdDupUsage(cmd *kingpin.CmdClause, opts *DupOptions) error {
|
||||
|
||||
// CmdDups will update the given issue as being a duplicate by the given dup issue
|
||||
// and will attempt to resolve the dup issue
|
||||
func CmdDup(o *oreo.Client, opts *DupOptions) error {
|
||||
if err := jira.LinkIssues(o, opts.Endpoint.Value, &opts.LinkIssueRequest); err != nil {
|
||||
func CmdDup(o *oreo.Client, globals *jiracli.GlobalOptions, opts *DupOptions) error {
|
||||
if err := jira.LinkIssues(o, globals.Endpoint.Value, &opts.LinkIssueRequest); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.OutwardIssue.Key, opts.Endpoint.Value, opts.OutwardIssue.Key)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.OutwardIssue.Key, globals.Endpoint.Value, opts.OutwardIssue.Key)
|
||||
|
||||
meta, err := jira.GetIssueTransitions(o, opts.Endpoint.Value, opts.InwardIssue.Key)
|
||||
meta, err := jira.GetIssueTransitions(o, globals.Endpoint.Value, opts.InwardIssue.Key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -81,7 +78,7 @@ func CmdDup(o *oreo.Client, opts *DupOptions) error {
|
||||
issueUpdate := jiradata.IssueUpdate{
|
||||
Transition: transMeta,
|
||||
}
|
||||
if err = jira.TransitionIssue(o, opts.Endpoint.Value, opts.InwardIssue.Key, &issueUpdate); err != nil {
|
||||
if err = jira.TransitionIssue(o, globals.Endpoint.Value, opts.InwardIssue.Key, &issueUpdate); err != nil {
|
||||
return err
|
||||
}
|
||||
// if we just started the issue now we need to stop it
|
||||
@@ -91,11 +88,11 @@ func CmdDup(o *oreo.Client, opts *DupOptions) error {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.InwardIssue.Key, opts.Endpoint.Value, opts.InwardIssue.Key)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.InwardIssue.Key, globals.Endpoint.Value, opts.InwardIssue.Key)
|
||||
|
||||
if opts.Browse.Value {
|
||||
if err := CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.OutwardIssue.Key}); err != nil {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.InwardIssue.Key})
|
||||
if err := CmdBrowse(globals, opts.OutwardIssue.Key); err != nil {
|
||||
return CmdBrowse(globals, opts.InwardIssue.Key)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-26
@@ -13,16 +13,16 @@ import (
|
||||
)
|
||||
|
||||
type EditOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiradata.IssueUpdate `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jira.SearchOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdEditRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdEditRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := EditOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("edit"),
|
||||
},
|
||||
Overrides: map[string]string{},
|
||||
@@ -30,23 +30,20 @@ func CmdEditRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegis
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Edit issue details",
|
||||
func() error {
|
||||
return CmdEdit(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdEditUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdEdit(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdEditUsage(cmd *kingpin.CmdClause, opts *EditOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("noedit", "Disable opening the editor").SetValue(&opts.SkipEditing)
|
||||
cmd.Flag("query", "Jira Query Language (JQL) expression for the search to edit multiple issues").Short('q').StringVar(&opts.Query)
|
||||
cmd.Flag("comment", "Comment message for issue").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
@@ -59,18 +56,18 @@ func CmdEditUsage(cmd *kingpin.CmdClause, opts *EditOptions) error {
|
||||
}
|
||||
|
||||
// Edit will get issue data and send to "edit" template
|
||||
func CmdEdit(o *oreo.Client, opts *EditOptions) error {
|
||||
func CmdEdit(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EditOptions) error {
|
||||
type templateInput struct {
|
||||
*jiradata.Issue `yaml:",inline"`
|
||||
Meta *jiradata.EditMeta `yaml:"meta" json:"meta"`
|
||||
Overrides map[string]string `yaml:"overrides" json:"overrides"`
|
||||
}
|
||||
if opts.Issue != "" {
|
||||
issueData, err := jira.GetIssue(o, opts.Endpoint.Value, opts.Issue, nil)
|
||||
issueData, err := jira.GetIssue(o, globals.Endpoint.Value, opts.Issue, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
editMeta, err := jira.GetIssueEditMeta(o, opts.Endpoint.Value, opts.Issue)
|
||||
editMeta, err := jira.GetIssueEditMeta(o, globals.Endpoint.Value, opts.Issue)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -81,24 +78,24 @@ func CmdEdit(o *oreo.Client, opts *EditOptions) error {
|
||||
Meta: editMeta,
|
||||
Overrides: opts.Overrides,
|
||||
}
|
||||
err = jiracli.EditLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
return jira.EditIssue(o, opts.Endpoint.Value, opts.Issue, &issueUpdate)
|
||||
err = jiracli.EditLoop(&opts.CommonOptions, &input, &issueUpdate, func() error {
|
||||
return jira.EditIssue(o, globals.Endpoint.Value, opts.Issue, &issueUpdate)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, opts.Endpoint.Value, opts.Issue)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
||||
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
}
|
||||
results, err := jira.Search(o, opts.Endpoint.Value, opts)
|
||||
results, err := jira.Search(o, globals.Endpoint.Value, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, issueData := range results.Issues {
|
||||
editMeta, err := jira.GetIssueEditMeta(o, opts.Endpoint.Value, issueData.Key)
|
||||
editMeta, err := jira.GetIssueEditMeta(o, globals.Endpoint.Value, issueData.Key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -108,16 +105,16 @@ func CmdEdit(o *oreo.Client, opts *EditOptions) error {
|
||||
Issue: issueData,
|
||||
Meta: editMeta,
|
||||
}
|
||||
err = jiracli.EditLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
return jira.EditIssue(o, opts.Endpoint.Value, issueData.Key, &issueUpdate)
|
||||
err = jiracli.EditLoop(&opts.CommonOptions, &input, &issueUpdate, func() error {
|
||||
return jira.EditIssue(o, globals.Endpoint.Value, issueData.Key, &issueUpdate)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("OK %s %s/browse/%s\n", issueData.Key, opts.Endpoint.Value, issueData.Key)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", issueData.Key, globals.Endpoint.Value, issueData.Key)
|
||||
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, issueData.Key})
|
||||
return CmdBrowse(globals, issueData.Key)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
+12
-15
@@ -9,43 +9,40 @@ import (
|
||||
)
|
||||
|
||||
type EditMetaOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdEditMetaRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdEditMetaRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
|
||||
opts := EditMetaOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("editmeta"),
|
||||
},
|
||||
}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"View 'edit' metadata",
|
||||
func() error {
|
||||
return CmdEditMeta(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdEditMetaUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdEditMeta(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdEditMetaUsage(cmd *kingpin.CmdClause, opts *EditMetaOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Arg("ISSUE", "edit metadata for issue id").Required().StringVar(&opts.Issue)
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditMeta will get issue edit metadata and send to "editmeta" template
|
||||
func CmdEditMeta(o *oreo.Client, opts *EditMetaOptions) error {
|
||||
editMeta, err := jira.GetIssueEditMeta(o, opts.Endpoint.Value, opts.Issue)
|
||||
func CmdEditMeta(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EditMetaOptions) error {
|
||||
editMeta, err := jira.GetIssueEditMeta(o, globals.Endpoint.Value, opts.Issue)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -53,7 +50,7 @@ func CmdEditMeta(o *oreo.Client, opts *EditMetaOptions) error {
|
||||
return err
|
||||
}
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,21 +15,21 @@ type ExportTemplatesOptions struct {
|
||||
Dir string `yaml:"dir,omitempty" json:"dir,omitempty"`
|
||||
}
|
||||
|
||||
func CmdExportTemplatesRegistry(fig *figtree.FigTree) *jiracli.CommandRegistryEntry {
|
||||
func CmdExportTemplatesRegistry() *jiracli.CommandRegistryEntry {
|
||||
opts := ExportTemplatesOptions{}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Export templates for customizations",
|
||||
func() error {
|
||||
return CmdExportTemplates(&opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.Dir == "" {
|
||||
opts.Dir = fmt.Sprintf("%s/.jira.d/templates", jiracli.Homedir())
|
||||
}
|
||||
return CmdExportTemplatesUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdExportTemplates(&opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-10
@@ -8,27 +8,26 @@ import (
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdFieldsRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := jiracli.GlobalOptions{
|
||||
func CmdFieldsRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("fields"),
|
||||
}
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Prints all fields, both System and Custom",
|
||||
func() error {
|
||||
return CmdFields(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
err := jiracli.GlobalUsage(cmd, &opts)
|
||||
jiracli.TemplateUsage(cmd, &opts)
|
||||
return err
|
||||
return nil
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdFields(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields will send data from /rest/api/2/field API to "fields" template
|
||||
func CmdFields(o *oreo.Client, opts *jiracli.GlobalOptions) error {
|
||||
data, err := jira.GetFields(o, opts.Endpoint.Value)
|
||||
func CmdFields(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.CommonOptions) error {
|
||||
data, err := jira.GetFields(o, globals.Endpoint.Value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+15
-18
@@ -13,12 +13,12 @@ import (
|
||||
)
|
||||
|
||||
type IssueLinkOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiradata.LinkIssueRequest `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
LinkType string `yaml:"linktype,omitempty" json:"linktype,omitempty"`
|
||||
}
|
||||
|
||||
func CmdIssueLinkRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdIssueLinkRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := IssueLinkOptions{
|
||||
LinkIssueRequest: jiradata.LinkIssueRequest{
|
||||
Type: &jiradata.IssueLinkType{},
|
||||
@@ -28,23 +28,20 @@ func CmdIssueLinkRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.Command
|
||||
}
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Link two issues",
|
||||
func() error {
|
||||
return CmdIssueLink(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdIssueLinkUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdIssueLink(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdIssueLinkUsage(cmd *kingpin.CmdClause, opts *IssueLinkOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("comment", "Comment message when linking issue").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Comment = &jiradata.Comment{
|
||||
Body: jiracli.FlagValue(ctx, "comment"),
|
||||
@@ -59,17 +56,17 @@ func CmdIssueLinkUsage(cmd *kingpin.CmdClause, opts *IssueLinkOptions) error {
|
||||
|
||||
// CmdBlock will update the given issue as being a duplicate by the given dup issue
|
||||
// and will attempt to resolve the dup issue
|
||||
func CmdIssueLink(o *oreo.Client, opts *IssueLinkOptions) error {
|
||||
if err := jira.LinkIssues(o, opts.Endpoint.Value, &opts.LinkIssueRequest); err != nil {
|
||||
func CmdIssueLink(o *oreo.Client, globals *jiracli.GlobalOptions, opts *IssueLinkOptions) error {
|
||||
if err := jira.LinkIssues(o, globals.Endpoint.Value, &opts.LinkIssueRequest); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.InwardIssue.Key, opts.Endpoint.Value, opts.InwardIssue.Key)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.OutwardIssue.Key, opts.Endpoint.Value, opts.OutwardIssue.Key)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.InwardIssue.Key, globals.Endpoint.Value, opts.InwardIssue.Key)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.OutwardIssue.Key, globals.Endpoint.Value, opts.OutwardIssue.Key)
|
||||
|
||||
if opts.Browse.Value {
|
||||
if err := CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.OutwardIssue.Key}); err != nil {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.InwardIssue.Key})
|
||||
if err := CmdBrowse(globals, opts.OutwardIssue.Key); err != nil {
|
||||
return CmdBrowse(globals, opts.InwardIssue.Key)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,34 +8,31 @@ import (
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdIssueLinkTypesRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := jiracli.GlobalOptions{
|
||||
func CmdIssueLinkTypesRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("issuelinktypes"),
|
||||
}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Show the issue link types",
|
||||
func() error {
|
||||
return CmdIssueLinkTypes(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdIssueLinkTypesUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdIssueLinkTypes(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdIssueLinkTypesUsage(cmd *kingpin.CmdClause, opts *jiracli.GlobalOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, opts); err != nil {
|
||||
return err
|
||||
}
|
||||
func CmdIssueLinkTypesUsage(cmd *kingpin.CmdClause, opts *jiracli.CommonOptions) error {
|
||||
jiracli.TemplateUsage(cmd, opts)
|
||||
return nil
|
||||
}
|
||||
|
||||
// CmdIssueLinkTypes will get issue link type data and send to "issuelinktypes" template
|
||||
func CmdIssueLinkTypes(o *oreo.Client, opts *jiracli.GlobalOptions) error {
|
||||
data, err := jira.GetIssueLinkTypes(o, opts.Endpoint.Value)
|
||||
func CmdIssueLinkTypes(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.CommonOptions) error {
|
||||
data, err := jira.GetIssueLinkTypes(o, globals.Endpoint.Value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+10
-13
@@ -12,45 +12,42 @@ import (
|
||||
)
|
||||
|
||||
type IssueTypesOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Project string `yaml:"project,omitempty" json:"project,omitempty"`
|
||||
}
|
||||
|
||||
func CmdIssueTypesRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdIssueTypesRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := IssueTypesOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("issuetypes"),
|
||||
},
|
||||
}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Show issue types for a project",
|
||||
func() error {
|
||||
return CmdIssueTypes(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdIssueTypesUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdIssueTypes(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdIssueTypesUsage(cmd *kingpin.CmdClause, opts *IssueTypesOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("project", "project to list issueTypes").Short('p').StringVar(&opts.Project)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CmdIssueTypes will get available issueTypes for project and send to the "issueTypes" template
|
||||
func CmdIssueTypes(o *oreo.Client, opts *IssueTypesOptions) error {
|
||||
func CmdIssueTypes(o *oreo.Client, globals *jiracli.GlobalOptions, opts *IssueTypesOptions) error {
|
||||
if opts.Project == "" {
|
||||
return fmt.Errorf("Project Required.")
|
||||
}
|
||||
data, err := jira.GetIssueCreateMetaProject(o, opts.Endpoint.Value, opts.Project)
|
||||
data, err := jira.GetIssueCreateMetaProject(o, globals.Endpoint.Value, opts.Project)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+11
-14
@@ -13,37 +13,34 @@ import (
|
||||
)
|
||||
|
||||
type LabelsAddOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
Labels []string `yaml:"labels,omitempty" json:"labels,omitempty"`
|
||||
}
|
||||
|
||||
func CmdLabelsAddRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdLabelsAddRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := LabelsAddOptions{}
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Add labels to an issue",
|
||||
func() error {
|
||||
return CmdLabelsAdd(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdLabelsAddUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdLabelsAdd(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdLabelsAddUsage(cmd *kingpin.CmdClause, opts *LabelsAddOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Arg("ISSUE", "issue id to modify labels").Required().StringVar(&opts.Issue)
|
||||
cmd.Arg("LABEL", "label to add to issue").Required().StringsVar(&opts.Labels)
|
||||
return nil
|
||||
}
|
||||
|
||||
// CmdLabels will add labels on a given issue
|
||||
func CmdLabelsAdd(o *oreo.Client, opts *LabelsAddOptions) error {
|
||||
func CmdLabelsAdd(o *oreo.Client, globals *jiracli.GlobalOptions, opts *LabelsAddOptions) error {
|
||||
ops := jiradata.FieldOperations{}
|
||||
for _, label := range opts.Labels {
|
||||
ops = append(ops, jiradata.FieldOperation{
|
||||
@@ -56,12 +53,12 @@ func CmdLabelsAdd(o *oreo.Client, opts *LabelsAddOptions) error {
|
||||
},
|
||||
}
|
||||
|
||||
if err := jira.EditIssue(o, opts.Endpoint.Value, opts.Issue, &issueUpdate); err != nil {
|
||||
if err := jira.EditIssue(o, globals.Endpoint.Value, opts.Issue, &issueUpdate); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, opts.Endpoint.Value, opts.Issue)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+11
-14
@@ -13,37 +13,34 @@ import (
|
||||
)
|
||||
|
||||
type LabelsRemoveOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
Labels []string `yaml:"labels,omitempty" json:"labels,omitempty"`
|
||||
}
|
||||
|
||||
func CmdLabelsRemoveRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdLabelsRemoveRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := LabelsRemoveOptions{}
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Remove labels from an issue",
|
||||
func() error {
|
||||
return CmdLabelsRemove(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdLabelsRemoveUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdLabelsRemove(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdLabelsRemoveUsage(cmd *kingpin.CmdClause, opts *LabelsRemoveOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
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 CmdLabelsRemove(o *oreo.Client, opts *LabelsRemoveOptions) error {
|
||||
func CmdLabelsRemove(o *oreo.Client, globals *jiracli.GlobalOptions, opts *LabelsRemoveOptions) error {
|
||||
ops := jiradata.FieldOperations{}
|
||||
for _, label := range opts.Labels {
|
||||
ops = append(ops, jiradata.FieldOperation{
|
||||
@@ -56,13 +53,13 @@ func CmdLabelsRemove(o *oreo.Client, opts *LabelsRemoveOptions) error {
|
||||
},
|
||||
}
|
||||
|
||||
err := jira.EditIssue(o, opts.Endpoint.Value, opts.Issue, &issueUpdate)
|
||||
err := jira.EditIssue(o, globals.Endpoint.Value, opts.Issue, &issueUpdate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, opts.Endpoint.Value, opts.Issue)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+11
-14
@@ -13,37 +13,34 @@ import (
|
||||
)
|
||||
|
||||
type LabelsSetOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
Labels []string `yaml:"labels,omitempty" json:"labels,omitempty"`
|
||||
}
|
||||
|
||||
func CmdLabelsSetRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdLabelsSetRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := LabelsSetOptions{}
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Set labels on an issue",
|
||||
func() error {
|
||||
return CmdLabelsSet(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdLabelsSetUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdLabelsSet(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdLabelsSetUsage(cmd *kingpin.CmdClause, opts *LabelsSetOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Arg("ISSUE", "issue id to modify labels").Required().StringVar(&opts.Issue)
|
||||
cmd.Arg("LABEL", "label to set on issue").Required().StringsVar(&opts.Labels)
|
||||
return nil
|
||||
}
|
||||
|
||||
// CmdLabels will set labels on a given issue
|
||||
func CmdLabelsSet(o *oreo.Client, opts *LabelsSetOptions) error {
|
||||
func CmdLabelsSet(o *oreo.Client, globals *jiracli.GlobalOptions, opts *LabelsSetOptions) error {
|
||||
issueUpdate := jiradata.IssueUpdate{
|
||||
Update: jiradata.FieldOperationsMap{
|
||||
"labels": jiradata.FieldOperations{
|
||||
@@ -54,12 +51,12 @@ func CmdLabelsSet(o *oreo.Client, opts *LabelsSetOptions) error {
|
||||
},
|
||||
}
|
||||
|
||||
if err := jira.EditIssue(o, opts.Endpoint.Value, opts.Issue, &issueUpdate); err != nil {
|
||||
if err := jira.EditIssue(o, globals.Endpoint.Value, opts.Issue, &issueUpdate); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, opts.Endpoint.Value, opts.Issue)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+10
-13
@@ -9,23 +9,20 @@ import (
|
||||
)
|
||||
|
||||
type ListOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jira.SearchOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
}
|
||||
|
||||
func CmdListRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdListRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := ListOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("list"),
|
||||
},
|
||||
}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Prints list of issues for given search criteria",
|
||||
func() error {
|
||||
return CmdList(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.MaxResults == 0 {
|
||||
opts.MaxResults = 500
|
||||
@@ -38,14 +35,14 @@ func CmdListRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegis
|
||||
}
|
||||
return CmdListUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdList(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdListUsage(cmd *kingpin.CmdClause, opts *ListOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("assignee", "User assigned the issue").Short('a').StringVar(&opts.Assignee)
|
||||
cmd.Flag("component", "Component to search for").Short('c').StringVar(&opts.Component)
|
||||
cmd.Flag("issuetype", "Issue type to search for").Short('i').StringVar(&opts.IssueType)
|
||||
@@ -60,8 +57,8 @@ func CmdListUsage(cmd *kingpin.CmdClause, opts *ListOptions) error {
|
||||
}
|
||||
|
||||
// List will query jira and send data to "list" template
|
||||
func CmdList(o *oreo.Client, opts *ListOptions) error {
|
||||
data, err := jira.Search(o, opts.Endpoint.Value, opts)
|
||||
func CmdList(o *oreo.Client, globals *jiracli.GlobalOptions, opts *ListOptions) error {
|
||||
data, err := jira.Search(o, globals.Endpoint.Value, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+12
-12
@@ -12,16 +12,16 @@ import (
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdLoginRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := jiracli.GlobalOptions{}
|
||||
func CmdLoginRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := jiracli.CommonOptions{}
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Attempt to login into jira server",
|
||||
func() error {
|
||||
return CmdLogin(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return jiracli.GlobalUsage(cmd, &opts)
|
||||
return nil
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdLogin(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -45,19 +45,19 @@ func authCallback(req *http.Request, resp *http.Response) (*http.Response, error
|
||||
}
|
||||
|
||||
// CmdLogin will attempt to login into jira server
|
||||
func CmdLogin(o *oreo.Client, opts *jiracli.GlobalOptions) error {
|
||||
func CmdLogin(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.CommonOptions) error {
|
||||
ua := o.WithoutRedirect().WithRetries(0).WithoutCallbacks().WithPostCallback(authCallback)
|
||||
for {
|
||||
if session, err := jira.GetSession(o, opts.Endpoint.Value); err != nil {
|
||||
if session, err := jira.GetSession(o, globals.Endpoint.Value); err != nil {
|
||||
// No active session so try to create a new one
|
||||
_, err := jira.NewSession(ua, opts.Endpoint.Value, opts)
|
||||
_, err := jira.NewSession(ua, globals.Endpoint.Value, globals)
|
||||
if err != nil {
|
||||
// reset password on failed session
|
||||
opts.SetPass("")
|
||||
globals.SetPass("")
|
||||
log.Errorf("%s", err)
|
||||
continue
|
||||
}
|
||||
fmt.Println(ansi.Color("OK", "green"), "New session for", opts.User)
|
||||
fmt.Println(ansi.Color("OK", "green"), "New session for", globals.User)
|
||||
break
|
||||
} else {
|
||||
fmt.Println(ansi.Color("OK", "green"), "Found session for", session.Name)
|
||||
|
||||
+11
-11
@@ -11,28 +11,28 @@ import (
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdLogoutRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := jiracli.GlobalOptions{}
|
||||
func CmdLogoutRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := jiracli.CommonOptions{}
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Deactivate sesssion with Jira server",
|
||||
func() error {
|
||||
return CmdLogout(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return jiracli.GlobalUsage(cmd, &opts)
|
||||
return nil
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdLogout(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// CmdLogout will attempt to terminate an active Jira session
|
||||
func CmdLogout(o *oreo.Client, opts *jiracli.GlobalOptions) error {
|
||||
func CmdLogout(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.CommonOptions) error {
|
||||
ua := o.WithoutRedirect().WithRetries(0).WithoutCallbacks()
|
||||
err := jira.DeleteSession(ua, opts.Endpoint.Value)
|
||||
err := jira.DeleteSession(ua, globals.Endpoint.Value)
|
||||
if err == nil {
|
||||
fmt.Println(ansi.Color("OK", "green"), "Terminated session for", opts.User)
|
||||
fmt.Println(ansi.Color("OK", "green"), "Terminated session for", globals.User)
|
||||
} else {
|
||||
fmt.Printf("%s Failed to terminate session for %s: %s", ansi.Color("ERROR", "red"), opts.User, err)
|
||||
fmt.Printf("%s Failed to terminate session for %s: %s", ansi.Color("ERROR", "red"), globals.User, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+13
-16
@@ -13,32 +13,29 @@ import (
|
||||
)
|
||||
|
||||
type RankOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
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(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdRankRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := RankOptions{}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Mark issues as blocker",
|
||||
func() error {
|
||||
return CmdRank(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdRankUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdRank(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdRankUsage(cmd *kingpin.CmdClause, opts *RankOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
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)
|
||||
@@ -46,7 +43,7 @@ func CmdRankUsage(cmd *kingpin.CmdClause, opts *RankOptions) error {
|
||||
}
|
||||
|
||||
// CmdRank order two issue
|
||||
func CmdRank(o *oreo.Client, opts *RankOptions) error {
|
||||
func CmdRank(o *oreo.Client, globals *jiracli.GlobalOptions, opts *RankOptions) error {
|
||||
req := &jiradata.RankRequest{
|
||||
Issues: []string{opts.First},
|
||||
}
|
||||
@@ -57,16 +54,16 @@ func CmdRank(o *oreo.Client, opts *RankOptions) error {
|
||||
req.RankBeforeIssue = opts.Second
|
||||
}
|
||||
|
||||
if err := jira.RankIssues(o, opts.Endpoint.Value, req); err != nil {
|
||||
if err := jira.RankIssues(o, globals.Endpoint.Value, req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.First, opts.Endpoint.Value, opts.First)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Second, opts.Endpoint.Value, opts.Second)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.First, globals.Endpoint.Value, opts.First)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Second, globals.Endpoint.Value, opts.Second)
|
||||
|
||||
if opts.Browse.Value {
|
||||
if err := CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.First}); err != nil {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Second})
|
||||
if err := CmdBrowse(globals, opts.First); err != nil {
|
||||
return CmdBrowse(globals, opts.Second)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-12
@@ -15,38 +15,35 @@ import (
|
||||
)
|
||||
|
||||
type RequestOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Method string `yaml:"method,omitempty" json:"method,omitempty"`
|
||||
URI string `yaml:"uri,omitempty" json:"uri,omitempty"`
|
||||
Data string `yaml:"data,omitempty" json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func CmdRequestRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdRequestRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := RequestOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("request"),
|
||||
},
|
||||
}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Open issue in requestr",
|
||||
func() error {
|
||||
return CmdRequest(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.Method == "" {
|
||||
opts.Method = "GET"
|
||||
}
|
||||
return CmdRequestUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdRequest(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdRequestUsage(cmd *kingpin.CmdClause, opts *RequestOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
cmd.Flag("method", "HTTP request method to use").Short('m').EnumVar(&opts.Method, "GET", "PUT", "POST", "DELETE")
|
||||
cmd.Arg("API", "Path to Jira API (ie: /rest/api/2/issue)").Required().StringVar(&opts.URI)
|
||||
cmd.Arg("JSON", "JSON Content to send to API").Required().StringVar(&opts.Data)
|
||||
@@ -55,10 +52,10 @@ func CmdRequestUsage(cmd *kingpin.CmdClause, opts *RequestOptions) error {
|
||||
}
|
||||
|
||||
// CmdRequest open the default system requestr to the provided issue
|
||||
func CmdRequest(o *oreo.Client, opts *RequestOptions) error {
|
||||
func CmdRequest(o *oreo.Client, globals *jiracli.GlobalOptions, opts *RequestOptions) error {
|
||||
uri := opts.URI
|
||||
if !strings.HasPrefix(uri, "http") {
|
||||
uri = opts.Endpoint.Value + uri
|
||||
uri = globals.Endpoint.Value + uri
|
||||
}
|
||||
|
||||
parsedURI, err := url.Parse(uri)
|
||||
|
||||
+18
-21
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
type SubtaskOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiradata.IssueUpdate `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Project string `yaml:"project,omitempty" json:"project,omitempty"`
|
||||
IssueType string `yaml:"issuetype,omitempty" json:"issuetype,omitempty"`
|
||||
@@ -21,9 +21,9 @@ type SubtaskOptions struct {
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdSubtaskRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdSubtaskRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := SubtaskOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("subtask"),
|
||||
},
|
||||
Overrides: map[string]string{},
|
||||
@@ -31,26 +31,23 @@ func CmdSubtaskRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRe
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Subtask issue",
|
||||
func() error {
|
||||
return CmdSubtask(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.IssueType == "" {
|
||||
opts.IssueType = "Sub-task"
|
||||
}
|
||||
return CmdSubtaskUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdSubtask(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdSubtaskUsage(cmd *kingpin.CmdClause, opts *SubtaskOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("noedit", "Disable opening the editor").SetValue(&opts.SkipEditing)
|
||||
cmd.Flag("project", "project to subtask issue in").Short('p').StringVar(&opts.Project)
|
||||
cmd.Flag("comment", "Comment message for issue").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
@@ -64,14 +61,14 @@ func CmdSubtaskUsage(cmd *kingpin.CmdClause, opts *SubtaskOptions) error {
|
||||
|
||||
// CmdSubtask sends the subtask-metadata to the "subtask" template for editing, then
|
||||
// will parse the edited document as YAML and submit the document to jira.
|
||||
func CmdSubtask(o *oreo.Client, opts *SubtaskOptions) error {
|
||||
func CmdSubtask(o *oreo.Client, globals *jiracli.GlobalOptions, opts *SubtaskOptions) error {
|
||||
type templateInput struct {
|
||||
Meta *jiradata.IssueType `yaml:"meta" json:"meta"`
|
||||
Overrides map[string]string `yaml:"overrides" json:"overrides"`
|
||||
Parent *jiradata.Issue `yaml:"parent" json:"parent"`
|
||||
}
|
||||
|
||||
parent, err := jira.GetIssue(o, opts.Endpoint.Value, opts.Issue, nil)
|
||||
parent, err := jira.GetIssue(o, globals.Endpoint.Value, opts.Issue, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -86,7 +83,7 @@ func CmdSubtask(o *oreo.Client, opts *SubtaskOptions) error {
|
||||
return fmt.Errorf("Failed to find Project field in parent issue")
|
||||
}
|
||||
|
||||
createMeta, err := jira.GetIssueCreateMetaIssueType(o, opts.Endpoint.Value, opts.Project, opts.IssueType)
|
||||
createMeta, err := jira.GetIssueCreateMetaIssueType(o, globals.Endpoint.Value, opts.Project, opts.IssueType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -99,21 +96,21 @@ func CmdSubtask(o *oreo.Client, opts *SubtaskOptions) error {
|
||||
}
|
||||
input.Overrides["project"] = opts.Project
|
||||
input.Overrides["issuetype"] = opts.IssueType
|
||||
input.Overrides["user"] = opts.User.Value
|
||||
input.Overrides["user"] = globals.User.Value
|
||||
|
||||
var issueResp *jiradata.IssueCreateResponse
|
||||
err = jiracli.EditLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
issueResp, err = jira.CreateIssue(o, opts.Endpoint.Value, &issueUpdate)
|
||||
err = jiracli.EditLoop(&opts.CommonOptions, &input, &issueUpdate, func() error {
|
||||
issueResp, err = jira.CreateIssue(o, globals.Endpoint.Value, &issueUpdate)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("OK %s %s/browse/%s\n", issueResp.Key, opts.Endpoint.Value, issueResp.Key)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", issueResp.Key, globals.Endpoint.Value, issueResp.Key)
|
||||
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, issueResp.Key})
|
||||
return CmdBrowse(globals, issueResp.Key)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+7
-10
@@ -7,27 +7,24 @@ import (
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdTakeRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdTakeRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := AssignOptions{}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Assign issue to yourself",
|
||||
func() error {
|
||||
opts.Assignee = opts.User.Value
|
||||
return CmdAssign(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdAssignUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
opts.Assignee = globals.User.Value
|
||||
return CmdAssign(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdTakeUsage(cmd *kingpin.CmdClause, opts *AssignOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Arg("ISSUE", "issue to assign").Required().StringVar(&opts.Issue)
|
||||
return nil
|
||||
}
|
||||
|
||||
+16
-19
@@ -14,16 +14,16 @@ import (
|
||||
)
|
||||
|
||||
type TransitionOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"`
|
||||
Transition string `yaml:"transition,omitempty" json:"transition,omitempty"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
Resolution string `yaml:"resolution,omitempty" json:"resolution,omitempty"`
|
||||
}
|
||||
|
||||
func CmdTransitionRegistry(fig *figtree.FigTree, o *oreo.Client, transition string) *jiracli.CommandRegistryEntry {
|
||||
func CmdTransitionRegistry(o *oreo.Client, transition string) *jiracli.CommandRegistryEntry {
|
||||
opts := TransitionOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("transition"),
|
||||
},
|
||||
Overrides: map[string]string{},
|
||||
@@ -37,25 +37,22 @@ func CmdTransitionRegistry(fig *figtree.FigTree, o *oreo.Client, transition stri
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
help,
|
||||
func() error {
|
||||
return CmdTransition(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.Transition == "" {
|
||||
opts.Transition = transition
|
||||
}
|
||||
return CmdTransitionUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdTransition(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdTransitionUsage(cmd *kingpin.CmdClause, opts *TransitionOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("noedit", "Disable opening the editor").SetValue(&opts.SkipEditing)
|
||||
cmd.Flag("comment", "Comment message for issue").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Overrides["comment"] = jiracli.FlagValue(ctx, "comment")
|
||||
@@ -70,13 +67,13 @@ func CmdTransitionUsage(cmd *kingpin.CmdClause, opts *TransitionOptions) error {
|
||||
}
|
||||
|
||||
// CmdTransition will move state of the given issue to the given transtion
|
||||
func CmdTransition(o *oreo.Client, opts *TransitionOptions) error {
|
||||
issueData, err := jira.GetIssue(o, opts.Endpoint.Value, opts.Issue, nil)
|
||||
func CmdTransition(o *oreo.Client, globals *jiracli.GlobalOptions, opts *TransitionOptions) error {
|
||||
issueData, err := jira.GetIssue(o, globals.Endpoint.Value, opts.Issue, nil)
|
||||
if err != nil {
|
||||
return jiracli.CliError(err)
|
||||
}
|
||||
|
||||
meta, err := jira.GetIssueTransitions(o, opts.Endpoint.Value, opts.Issue)
|
||||
meta, err := jira.GetIssueTransitions(o, globals.Endpoint.Value, opts.Issue)
|
||||
if err != nil {
|
||||
return jiracli.CliError(err)
|
||||
}
|
||||
@@ -128,16 +125,16 @@ func CmdTransition(o *oreo.Client, opts *TransitionOptions) error {
|
||||
Transition: transMeta,
|
||||
Overrides: opts.Overrides,
|
||||
}
|
||||
err = jiracli.EditLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
return jira.TransitionIssue(o, opts.Endpoint.Value, opts.Issue, &issueUpdate)
|
||||
err = jiracli.EditLoop(&opts.CommonOptions, &input, &issueUpdate, func() error {
|
||||
return jira.TransitionIssue(o, globals.Endpoint.Value, opts.Issue, &issueUpdate)
|
||||
})
|
||||
if err != nil {
|
||||
return jiracli.CliError(err)
|
||||
}
|
||||
fmt.Printf("OK %s %s/browse/%s\n", issueData.Key, opts.Endpoint.Value, issueData.Key)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", issueData.Key, globals.Endpoint.Value, issueData.Key)
|
||||
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+12
-15
@@ -9,42 +9,39 @@ import (
|
||||
)
|
||||
|
||||
type TransitionsOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdTransitionsRegistry(fig *figtree.FigTree, o *oreo.Client, defaultTemplate string) *jiracli.CommandRegistryEntry {
|
||||
func CmdTransitionsRegistry(o *oreo.Client, defaultTemplate string) *jiracli.CommandRegistryEntry {
|
||||
opts := TransitionsOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption(defaultTemplate),
|
||||
},
|
||||
}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"List valid issue transitions",
|
||||
func() error {
|
||||
return CmdTransitions(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdTransitionsUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdTransitions(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdTransitionsUsage(cmd *kingpin.CmdClause, opts *TransitionsOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Arg("ISSUE", "issue to list valid transitions").Required().StringVar(&opts.Issue)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Transitions will get issue edit metadata and send to "editmeta" template
|
||||
func CmdTransitions(o *oreo.Client, opts *TransitionsOptions) error {
|
||||
editMeta, err := jira.GetIssueTransitions(o, opts.Endpoint.Value, opts.Issue)
|
||||
func CmdTransitions(o *oreo.Client, globals *jiracli.GlobalOptions, opts *TransitionsOptions) error {
|
||||
editMeta, err := jira.GetIssueTransitions(o, globals.Endpoint.Value, opts.Issue)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -52,7 +49,7 @@ func CmdTransitions(o *oreo.Client, opts *TransitionsOptions) error {
|
||||
return err
|
||||
}
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+6
-9
@@ -7,26 +7,23 @@ import (
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdUnassignRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdUnassignRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := AssignOptions{}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Unassign an issue",
|
||||
func() error {
|
||||
return CmdAssign(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdAssignUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdAssign(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdUnassignUsage(cmd *kingpin.CmdClause, opts *AssignOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Arg("ISSUE", "issue to unassign").Required().StringVar(&opts.Issue)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -12,15 +12,12 @@ import (
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdUnexportTemplatesRegistry(fig *figtree.FigTree) *jiracli.CommandRegistryEntry {
|
||||
func CmdUnexportTemplatesRegistry() *jiracli.CommandRegistryEntry {
|
||||
opts := ExportTemplatesOptions{}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Remove unmodified exported templates",
|
||||
func() error {
|
||||
return CmdUnexportTemplates(&opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.Dir != "" {
|
||||
opts.Dir = fmt.Sprintf("%s/.jira.d/templates", jiracli.Homedir())
|
||||
@@ -28,6 +25,9 @@ func CmdUnexportTemplatesRegistry(fig *figtree.FigTree) *jiracli.CommandRegistry
|
||||
|
||||
return CmdExportTemplatesUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdUnexportTemplates(&opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-15
@@ -9,36 +9,33 @@ import (
|
||||
)
|
||||
|
||||
type ViewOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jira.IssueOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdViewRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdViewRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := ViewOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("view"),
|
||||
},
|
||||
}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Prints issue details",
|
||||
func() error {
|
||||
return CmdView(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdViewUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdView(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdViewUsage(cmd *kingpin.CmdClause, opts *ViewOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("expand", "field to expand for the issue").StringsVar(&opts.Expand)
|
||||
cmd.Flag("field", "field to return for the issue").StringsVar(&opts.Fields)
|
||||
cmd.Flag("property", "property to return for issue").StringsVar(&opts.Properties)
|
||||
@@ -47,8 +44,8 @@ func CmdViewUsage(cmd *kingpin.CmdClause, opts *ViewOptions) error {
|
||||
}
|
||||
|
||||
// View will get issue data and send to "view" template
|
||||
func CmdView(o *oreo.Client, opts *ViewOptions) error {
|
||||
data, err := jira.GetIssue(o, opts.Endpoint.Value, opts.Issue, opts)
|
||||
func CmdView(o *oreo.Client, globals *jiracli.GlobalOptions, opts *ViewOptions) error {
|
||||
data, err := jira.GetIssue(o, globals.Endpoint.Value, opts.Issue, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -56,7 +53,7 @@ func CmdView(o *oreo.Client, opts *ViewOptions) error {
|
||||
return err
|
||||
}
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+13
-16
@@ -19,34 +19,31 @@ const (
|
||||
)
|
||||
|
||||
type VoteOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
Action VoteAction `yaml:"-" json:"-"`
|
||||
}
|
||||
|
||||
func CmdVoteRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdVoteRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := VoteOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{},
|
||||
CommonOptions: jiracli.CommonOptions{},
|
||||
Action: VoteUP,
|
||||
}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Vote up/down an issue",
|
||||
func() error {
|
||||
return CmdVote(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdVoteUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdVote(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdVoteUsage(cmd *kingpin.CmdClause, opts *VoteOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("down", "downvote the issue").Short('d').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Action = VoteDown
|
||||
return nil
|
||||
@@ -56,20 +53,20 @@ func CmdVoteUsage(cmd *kingpin.CmdClause, opts *VoteOptions) error {
|
||||
}
|
||||
|
||||
// Vote will up/down vote an issue
|
||||
func CmdVote(o *oreo.Client, opts *VoteOptions) error {
|
||||
func CmdVote(o *oreo.Client, globals *jiracli.GlobalOptions, opts *VoteOptions) error {
|
||||
if opts.Action == VoteUP {
|
||||
if err := jira.IssueAddVote(o, opts.Endpoint.Value, opts.Issue); err != nil {
|
||||
if err := jira.IssueAddVote(o, globals.Endpoint.Value, opts.Issue); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := jira.IssueRemoveVote(o, opts.Endpoint.Value, opts.Issue); err != nil {
|
||||
if err := jira.IssueRemoveVote(o, globals.Endpoint.Value, opts.Issue); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, opts.Endpoint.Value, opts.Issue)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
||||
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+14
-17
@@ -19,35 +19,32 @@ const (
|
||||
)
|
||||
|
||||
type WatchOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
Watcher string `yaml:"watcher,omitempty" json:"watcher,omitempty"`
|
||||
Action WatchAction `yaml:"-" json:"-"`
|
||||
}
|
||||
|
||||
func CmdWatchRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdWatchRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := WatchOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{},
|
||||
CommonOptions: jiracli.CommonOptions{},
|
||||
Action: WatcherAdd,
|
||||
}
|
||||
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Add/Remove watcher to issue",
|
||||
func() error {
|
||||
return CmdWatch(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdWatchUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdWatch(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdWatchUsage(cmd *kingpin.CmdClause, opts *WatchOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("remove", "remove watcher from issue").Short('r').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Action = WatcherRemove
|
||||
return nil
|
||||
@@ -59,24 +56,24 @@ func CmdWatchUsage(cmd *kingpin.CmdClause, opts *WatchOptions) error {
|
||||
|
||||
// CmdWatch will add the given watcher to the issue (or remove the watcher
|
||||
// with the 'remove' flag)
|
||||
func CmdWatch(o *oreo.Client, opts *WatchOptions) error {
|
||||
func CmdWatch(o *oreo.Client, globals *jiracli.GlobalOptions, opts *WatchOptions) error {
|
||||
if opts.Watcher == "" {
|
||||
opts.Watcher = opts.User.Value
|
||||
opts.Watcher = globals.User.Value
|
||||
}
|
||||
if opts.Action == WatcherAdd {
|
||||
if err := jira.IssueAddWatcher(o, opts.Endpoint.Value, opts.Issue, opts.Watcher); err != nil {
|
||||
if err := jira.IssueAddWatcher(o, globals.Endpoint.Value, opts.Issue, opts.Watcher); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := jira.IssueRemoveWatcher(o, opts.Endpoint.Value, opts.Issue, opts.Watcher); err != nil {
|
||||
if err := jira.IssueRemoveWatcher(o, globals.Endpoint.Value, opts.Issue, opts.Watcher); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, opts.Endpoint.Value, opts.Issue)
|
||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
||||
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
+14
-17
@@ -10,36 +10,33 @@ import (
|
||||
)
|
||||
|
||||
type WorklogAddOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiradata.Worklog `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdWorklogAddRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdWorklogAddRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := WorklogAddOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("worklog"),
|
||||
},
|
||||
}
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Add a worklog to an issue",
|
||||
func() error {
|
||||
return CmdWorklogAdd(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdWorklogAddUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdWorklogAdd(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdWorklogAddUsage(cmd *kingpin.CmdClause, opts *WorklogAddOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Flag("noedit", "Disable opening the editor").SetValue(&opts.SkipEditing)
|
||||
cmd.Flag("comment", "Comment message for worklog").Short('m').StringVar(&opts.Comment)
|
||||
cmd.Flag("time-spent", "Time spent working on issue").Short('T').StringVar(&opts.TimeSpent)
|
||||
@@ -50,16 +47,16 @@ func CmdWorklogAddUsage(cmd *kingpin.CmdClause, opts *WorklogAddOptions) error {
|
||||
// CmdWorklogAdd will attempt to add (action=add) a worklog to the given issue.
|
||||
// It will spawn the editor (unless --noedit isused) and post edited YAML
|
||||
// content as JSON to the worklog endpoint
|
||||
func CmdWorklogAdd(o *oreo.Client, opts *WorklogAddOptions) error {
|
||||
err := jiracli.EditLoop(&opts.GlobalOptions, &opts.Worklog, &opts.Worklog, func() error {
|
||||
_, err := jira.AddIssueWorklog(o, opts.Endpoint.Value, opts.Issue, opts)
|
||||
func CmdWorklogAdd(o *oreo.Client, globals *jiracli.GlobalOptions, opts *WorklogAddOptions) error {
|
||||
err := jiracli.EditLoop(&opts.CommonOptions, &opts.Worklog, &opts.Worklog, func() error {
|
||||
_, err := jira.AddIssueWorklog(o, globals.Endpoint.Value, opts.Issue, opts)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+12
-15
@@ -9,41 +9,38 @@ import (
|
||||
)
|
||||
|
||||
type WorklogListOptions struct {
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdWorklogListRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
func CmdWorklogListRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := WorklogListOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
CommonOptions: jiracli.CommonOptions{
|
||||
Template: figtree.NewStringOption("worklogs"),
|
||||
},
|
||||
}
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Prints the worklog data for given issue",
|
||||
func() error {
|
||||
return CmdWorklogList(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdWorklogListUsage(cmd, &opts)
|
||||
},
|
||||
func(globals *jiracli.GlobalOptions) error {
|
||||
return CmdWorklogList(o, globals, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdWorklogListUsage(cmd *kingpin.CmdClause, opts *WorklogListOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
|
||||
cmd.Arg("ISSUE", "issue id to fetch worklogs").Required().StringVar(&opts.Issue)
|
||||
return nil
|
||||
}
|
||||
|
||||
// // CmdWorklogList will get worklog data for given issue and sent to the "worklogs" template
|
||||
func CmdWorklogList(o *oreo.Client, opts *WorklogListOptions) error {
|
||||
data, err := jira.GetIssueWorklog(o, opts.Endpoint.Value, opts.Issue)
|
||||
func CmdWorklogList(o *oreo.Client, globals *jiracli.GlobalOptions, opts *WorklogListOptions) error {
|
||||
data, err := jira.GetIssueWorklog(o, globals.Endpoint.Value, opts.Issue)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -51,7 +48,7 @@ func CmdWorklogList(o *oreo.Client, opts *WorklogListOptions) error {
|
||||
return err
|
||||
}
|
||||
if opts.Browse.Value {
|
||||
return CmdBrowse(&BrowseOptions{opts.GlobalOptions, opts.Issue})
|
||||
return CmdBrowse(globals, opts.Issue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user