mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-18 20:23:28 +02:00
move commands from jiracli package to jiracmd package
This commit is contained in:
+1
-1
@@ -187,7 +187,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 *GlobalOptions, input interface{}, output interface{}, submit func() error) error {
|
||||
tmpFile, err := tmpTemplate(opts.Template.Value, input)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ type Error struct {
|
||||
error
|
||||
}
|
||||
|
||||
func cliError(cause error) error {
|
||||
func CliError(cause error) error {
|
||||
return &Error{
|
||||
errors.WithStack(cause),
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package jiracli
|
||||
|
||||
import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdFieldsRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
opts := GlobalOptions{
|
||||
Template: figtree.NewStringOption("fields"),
|
||||
}
|
||||
return &CommandRegistryEntry{
|
||||
"Prints all fields, both System and Custom",
|
||||
func() error {
|
||||
return CmdFields(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
err := GlobalUsage(cmd, &opts)
|
||||
TemplateUsage(cmd, &opts)
|
||||
return err
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields will send data from /rest/api/2/field API to "fields" template
|
||||
func CmdFields(o *oreo.Client, opts *GlobalOptions) error {
|
||||
data, err := jira.GetFields(o, opts.Endpoint.Value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return runTemplate(opts.Template.Value, data, nil)
|
||||
}
|
||||
@@ -44,7 +44,7 @@ func getTemplate(name string) (string, error) {
|
||||
} else if b != nil {
|
||||
return string(b), nil
|
||||
}
|
||||
if s, ok := allTemplates[name]; ok {
|
||||
if s, ok := AllTemplates[name]; ok {
|
||||
return s, nil
|
||||
}
|
||||
return "", fmt.Errorf("No Template found for %q", name)
|
||||
@@ -56,7 +56,7 @@ func tmpTemplate(templateName string, data interface{}) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
defer tmpFile.Close()
|
||||
return tmpFile.Name(), runTemplate(templateName, data, tmpFile)
|
||||
return tmpFile.Name(), RunTemplate(templateName, data, tmpFile)
|
||||
}
|
||||
|
||||
func TemplateProcessor() *template.Template {
|
||||
@@ -155,7 +155,7 @@ func TemplateProcessor() *template.Template {
|
||||
return template.New("gojira").Funcs(funcs)
|
||||
}
|
||||
|
||||
func runTemplate(templateName string, data interface{}, out io.Writer) error {
|
||||
func RunTemplate(templateName string, data interface{}, out io.Writer) error {
|
||||
|
||||
templateContent, err := getTemplate(templateName)
|
||||
if err != nil {
|
||||
@@ -194,7 +194,7 @@ func runTemplate(templateName string, data interface{}, out io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var allTemplates = map[string]string{
|
||||
var AllTemplates = map[string]string{
|
||||
"component-add": defaultComponentAddTemplate,
|
||||
"debug": defaultDebugTemplate,
|
||||
"fields": defaultDebugTemplate,
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ func tmpYml(tmpFilePrefix string) (*os.File, error) {
|
||||
return os.OpenFile(newFileName, os.O_RDWR|os.O_EXCL, 0600)
|
||||
}
|
||||
|
||||
func flagValue(ctx *kingpin.ParseContext, name string) string {
|
||||
func FlagValue(ctx *kingpin.ParseContext, name string) string {
|
||||
for _, elem := range ctx.Elements {
|
||||
if flag, ok := elem.Clause.(*kingpin.FlagClause); ok {
|
||||
if flag.Model().Name == name {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,38 +6,39 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type AssignOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdAssignRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := AssignOptions{}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Assign user to issue",
|
||||
func() error {
|
||||
return CmdAssign(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdAssignUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdAssignUsage(cmd *kingpin.CmdClause, opts *AssignOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Flag("default", "use default user for assignee").PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
if flagValue(ctx, "default") == "true" {
|
||||
if jiracli.FlagValue(ctx, "default") == "true" {
|
||||
opts.Assignee = "-1"
|
||||
}
|
||||
return nil
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,19 +6,20 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type BlockOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiradata.LinkIssueRequest `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
}
|
||||
|
||||
func CmdBlockRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
func CmdBlockRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := BlockOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("edit"),
|
||||
},
|
||||
LinkIssueRequest: jiradata.LinkIssueRequest{
|
||||
@@ -30,28 +31,28 @@ func CmdBlockRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntr
|
||||
},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Mark issues as blocker",
|
||||
func() error {
|
||||
return CmdBlock(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdBlockUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdBlockUsage(cmd *kingpin.CmdClause, opts *BlockOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
EditorUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Flag("comment", "Comment message when marking issue as blocker").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Comment = &jiradata.Comment{
|
||||
Body: flagValue(ctx, "comment"),
|
||||
Body: jiracli.FlagValue(ctx, "comment"),
|
||||
}
|
||||
return nil
|
||||
}).String()
|
||||
@@ -1,35 +1,36 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/pkg/browser"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type BrowseOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdBrowseRegistry(fig *figtree.FigTree) *CommandRegistryEntry {
|
||||
func CmdBrowseRegistry(fig *figtree.FigTree) *jiracli.CommandRegistryEntry {
|
||||
opts := BrowseOptions{}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Open issue in browser",
|
||||
func() error {
|
||||
return CmdBrowse(&opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdBrowseUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdBrowseUsage(cmd *kingpin.CmdClause, opts *BrowseOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
cmd.Arg("ISSUE", "Issue to browse to").Required().StringVar(&opts.Issue)
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,46 +6,47 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type CommentOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdCommentRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := CommentOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("comment"),
|
||||
},
|
||||
Overrides: map[string]string{},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Add comment to issue",
|
||||
func() error {
|
||||
return CmdComment(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdCommentUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdCommentUsage(cmd *kingpin.CmdClause, opts *CommentOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
EditorUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Flag("comment", "Comment message for issue").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Overrides["comment"] = flagValue(ctx, "comment")
|
||||
opts.Overrides["comment"] = jiracli.FlagValue(ctx, "comment")
|
||||
return nil
|
||||
}).String()
|
||||
cmd.Arg("ISSUE", "issue id to update").StringVar(&opts.Issue)
|
||||
@@ -60,7 +61,7 @@ func CmdComment(o *oreo.Client, opts *CommentOptions) error {
|
||||
}{
|
||||
opts.Overrides,
|
||||
}
|
||||
err := editLoop(&opts.GlobalOptions, &input, &comment, func() error {
|
||||
err := jiracli.EditLoop(&opts.GlobalOptions, &input, &comment, func() error {
|
||||
_, err := jira.IssueAddComment(o, opts.Endpoint.Value, opts.Issue, &comment)
|
||||
return err
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,41 +6,42 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type ComponentAddOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiradata.Component `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
}
|
||||
|
||||
func CmdComponentAddRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
func CmdComponentAddRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := ComponentAddOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("component-add"),
|
||||
},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Add component",
|
||||
func() error {
|
||||
return CmdComponentAdd(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdComponentAddUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdComponentAddUsage(cmd *kingpin.CmdClause, opts *ComponentAddOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
EditorUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
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)
|
||||
@@ -55,7 +56,7 @@ func CmdComponentAdd(o *oreo.Client, opts *ComponentAddOptions) error {
|
||||
var err error
|
||||
component := &jiradata.Component{}
|
||||
var resp *jiradata.Component
|
||||
err = editLoop(&opts.GlobalOptions, &opts.Component, component, func() error {
|
||||
err = jiracli.EditLoop(&opts.GlobalOptions, &opts.Component, component, func() error {
|
||||
resp, err = jira.CreateComponent(o, opts.Endpoint.Value, component)
|
||||
return err
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,39 +6,40 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type ComponentsOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Project string `yaml:"project,omitempty" json:"project,omitempty"`
|
||||
}
|
||||
|
||||
func CmdComponentsRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
func CmdComponentsRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := ComponentsOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("components"),
|
||||
},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Show components for a project",
|
||||
func() error {
|
||||
return CmdComponents(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdComponentsUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdComponentsUsage(cmd *kingpin.CmdClause, opts *ComponentsOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Flag("project", "project to list components").Short('p').StringVar(&opts.Project)
|
||||
|
||||
return nil
|
||||
@@ -53,5 +54,5 @@ func CmdComponents(o *oreo.Client, opts *ComponentsOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return runTemplate(opts.Template.Value, data, nil)
|
||||
return jiracli.RunTemplate(opts.Template.Value, data, nil)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -7,14 +7,15 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
yaml "gopkg.in/coryb/yaml.v2"
|
||||
)
|
||||
|
||||
type CreateOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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"`
|
||||
@@ -22,38 +23,38 @@ type CreateOptions struct {
|
||||
SaveFile string `yaml:"savefile,omitempty" json:"savefile,omitempty"`
|
||||
}
|
||||
|
||||
func CmdCreateRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
func CmdCreateRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := CreateOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("create"),
|
||||
},
|
||||
Overrides: map[string]string{},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Create issue",
|
||||
func() error {
|
||||
return CmdCreate(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdCreateUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdCreateUsage(cmd *kingpin.CmdClause, opts *CreateOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
EditorUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
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)
|
||||
cmd.Flag("comment", "Comment message for issue").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Overrides["comment"] = flagValue(ctx, "comment")
|
||||
opts.Overrides["comment"] = jiracli.FlagValue(ctx, "comment")
|
||||
return nil
|
||||
}).String()
|
||||
cmd.Flag("override", "Set issue property").Short('o').StringMapVar(&opts.Overrides)
|
||||
@@ -87,7 +88,7 @@ func CmdCreate(o *oreo.Client, opts *CreateOptions) error {
|
||||
input.Overrides["user"] = opts.User.Value
|
||||
|
||||
var issueResp *jiradata.IssueCreateResponse
|
||||
err = editLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
err = jiracli.EditLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
issueResp, err = jira.CreateIssue(o, opts.Endpoint.Value, &issueUpdate)
|
||||
return err
|
||||
})
|
||||
@@ -1,42 +1,43 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type CreateMetaOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdCreateMetaRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := CreateMetaOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("createmeta"),
|
||||
},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"View 'create' metadata",
|
||||
func() error {
|
||||
return CmdCreateMeta(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdCreateMetaUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdCreateMetaUsage(cmd *kingpin.CmdClause, opts *CreateMetaOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Flag("project", "project to fetch create metadata").Short('p').StringVar(&opts.Project)
|
||||
cmd.Flag("issuetype", "issuetype in project to fetch create metadata").Short('i').StringVar(&opts.IssueType)
|
||||
return nil
|
||||
@@ -51,5 +52,5 @@ func CmdCreateMeta(o *oreo.Client, opts *CreateMetaOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return runTemplate(opts.Template.Value, createMeta, nil)
|
||||
return jiracli.RunTemplate(opts.Template.Value, createMeta, nil)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,21 +6,22 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type DupOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdDupRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := DupOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("edit"),
|
||||
},
|
||||
LinkIssueRequest: jiradata.LinkIssueRequest{
|
||||
@@ -32,28 +33,28 @@ func CmdDupRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry
|
||||
},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Mark issues as duplicate",
|
||||
func() error {
|
||||
return CmdDup(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdDupUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdDupUsage(cmd *kingpin.CmdClause, opts *DupOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
EditorUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Flag("comment", "Comment message when marking issue as duplicate").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Comment = &jiradata.Comment{
|
||||
Body: flagValue(ctx, "comment"),
|
||||
Body: jiracli.FlagValue(ctx, "comment"),
|
||||
}
|
||||
return nil
|
||||
}).String()
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,50 +6,51 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type EditOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdEditRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := EditOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("edit"),
|
||||
},
|
||||
Overrides: map[string]string{},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Edit issue details",
|
||||
func() error {
|
||||
return CmdEdit(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdEditUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdEditUsage(cmd *kingpin.CmdClause, opts *EditOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
EditorUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
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 {
|
||||
opts.Overrides["comment"] = flagValue(ctx, "comment")
|
||||
opts.Overrides["comment"] = jiracli.FlagValue(ctx, "comment")
|
||||
return nil
|
||||
}).String()
|
||||
cmd.Flag("override", "Set issue property").Short('o').StringMapVar(&opts.Overrides)
|
||||
@@ -80,7 +81,7 @@ func CmdEdit(o *oreo.Client, opts *EditOptions) error {
|
||||
Meta: editMeta,
|
||||
Overrides: opts.Overrides,
|
||||
}
|
||||
err = editLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
err = jiracli.EditLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
return jira.EditIssue(o, opts.Endpoint.Value, opts.Issue, &issueUpdate)
|
||||
})
|
||||
if err != nil {
|
||||
@@ -107,7 +108,7 @@ func CmdEdit(o *oreo.Client, opts *EditOptions) error {
|
||||
Issue: issueData,
|
||||
Meta: editMeta,
|
||||
}
|
||||
err = editLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
err = jiracli.EditLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
return jira.EditIssue(o, opts.Endpoint.Value, issueData.Key, &issueUpdate)
|
||||
})
|
||||
if err != nil {
|
||||
@@ -1,43 +1,44 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type EditMetaOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdEditMetaRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
func CmdEditMetaRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
|
||||
opts := EditMetaOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("editmeta"),
|
||||
},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"View 'edit' metadata",
|
||||
func() error {
|
||||
return CmdEditMeta(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdEditMetaUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdEditMetaUsage(cmd *kingpin.CmdClause, opts *EditMetaOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Arg("ISSUE", "edit metadata for issue id").Required().StringVar(&opts.Issue)
|
||||
return nil
|
||||
}
|
||||
@@ -48,7 +49,7 @@ func CmdEditMeta(o *oreo.Client, opts *EditMetaOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := runTemplate(opts.Template.Value, editMeta, nil); err != nil {
|
||||
if err := jiracli.RunTemplate(opts.Template.Value, editMeta, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
if opts.Browse.Value {
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"path"
|
||||
|
||||
"github.com/coryb/figtree"
|
||||
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
@@ -15,18 +15,18 @@ type ExportTemplatesOptions struct {
|
||||
Dir string `yaml:"dir,omitempty" json:"dir,omitempty"`
|
||||
}
|
||||
|
||||
func CmdExportTemplatesRegistry(fig *figtree.FigTree) *CommandRegistryEntry {
|
||||
func CmdExportTemplatesRegistry(fig *figtree.FigTree) *jiracli.CommandRegistryEntry {
|
||||
opts := ExportTemplatesOptions{}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Export templates for customizations",
|
||||
func() error {
|
||||
return CmdExportTemplates(&opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.Dir == "" {
|
||||
opts.Dir = fmt.Sprintf("%s/.jira.d/templates", Homedir())
|
||||
opts.Dir = fmt.Sprintf("%s/.jira.d/templates", jiracli.Homedir())
|
||||
}
|
||||
return CmdExportTemplatesUsage(cmd, &opts)
|
||||
},
|
||||
@@ -46,7 +46,7 @@ func CmdExportTemplates(opts *ExportTemplatesOptions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
for name, template := range allTemplates {
|
||||
for name, template := range jiracli.AllTemplates {
|
||||
if opts.Template != "" && opts.Template != name {
|
||||
continue
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package jiracmd
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
func CmdFieldsRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := jiracli.GlobalOptions{
|
||||
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 {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
err := jiracli.GlobalUsage(cmd, &opts)
|
||||
jiracli.TemplateUsage(cmd, &opts)
|
||||
return err
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return jiracli.RunTemplate(opts.Template.Value, data, nil)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,18 +6,19 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type IssueLinkOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdIssueLinkRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := IssueLinkOptions{
|
||||
LinkIssueRequest: jiradata.LinkIssueRequest{
|
||||
Type: &jiradata.IssueLinkType{},
|
||||
@@ -25,28 +26,28 @@ func CmdIssueLinkRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistry
|
||||
OutwardIssue: &jiradata.IssueRef{},
|
||||
},
|
||||
}
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Link two issues",
|
||||
func() error {
|
||||
return CmdIssueLink(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdIssueLinkUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdIssueLinkUsage(cmd *kingpin.CmdClause, opts *IssueLinkOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
EditorUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Flag("comment", "Comment message when linking issue").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Comment = &jiradata.Comment{
|
||||
Body: flagValue(ctx, "comment"),
|
||||
Body: jiracli.FlagValue(ctx, "comment"),
|
||||
}
|
||||
return nil
|
||||
}).String()
|
||||
@@ -1,42 +1,43 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdIssueLinkTypesRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
opts := GlobalOptions{
|
||||
func CmdIssueLinkTypesRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("issuelinktypes"),
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Show the issue link types",
|
||||
func() error {
|
||||
return CmdIssueLinkTypes(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdIssueLinkTypesUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdIssueLinkTypesUsage(cmd *kingpin.CmdClause, opts *GlobalOptions) error {
|
||||
if err := GlobalUsage(cmd, opts); err != nil {
|
||||
func CmdIssueLinkTypesUsage(cmd *kingpin.CmdClause, opts *jiracli.GlobalOptions) error {
|
||||
if err := jiracli.GlobalUsage(cmd, opts); err != nil {
|
||||
return err
|
||||
}
|
||||
TemplateUsage(cmd, opts)
|
||||
jiracli.TemplateUsage(cmd, opts)
|
||||
return nil
|
||||
}
|
||||
|
||||
// CmdIssueLinkTypes will get issue link type data and send to "issuelinktypes" template
|
||||
func CmdIssueLinkTypes(o *oreo.Client, opts *GlobalOptions) error {
|
||||
func CmdIssueLinkTypes(o *oreo.Client, opts *jiracli.GlobalOptions) error {
|
||||
data, err := jira.GetIssueLinkTypes(o, opts.Endpoint.Value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return runTemplate(opts.Template.Value, data, nil)
|
||||
return jiracli.RunTemplate(opts.Template.Value, data, nil)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,39 +6,40 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type IssueTypesOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Project string `yaml:"project,omitempty" json:"project,omitempty"`
|
||||
}
|
||||
|
||||
func CmdIssueTypesRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
func CmdIssueTypesRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := IssueTypesOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("issuetypes"),
|
||||
},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Show issue types for a project",
|
||||
func() error {
|
||||
return CmdIssueTypes(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdIssueTypesUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdIssueTypesUsage(cmd *kingpin.CmdClause, opts *IssueTypesOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Flag("project", "project to list issueTypes").Short('p').StringVar(&opts.Project)
|
||||
|
||||
return nil
|
||||
@@ -53,5 +54,5 @@ func CmdIssueTypes(o *oreo.Client, opts *IssueTypesOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return runTemplate(opts.Template.Value, data, nil)
|
||||
return jiracli.RunTemplate(opts.Template.Value, data, nil)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,36 +6,37 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type LabelsAddOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdLabelsAddRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := LabelsAddOptions{}
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Add labels to an issue",
|
||||
func() error {
|
||||
return CmdLabelsAdd(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdLabelsAddUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdLabelsAddUsage(cmd *kingpin.CmdClause, opts *LabelsAddOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
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
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,36 +6,37 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type LabelsRemoveOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdLabelsRemoveRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := LabelsRemoveOptions{}
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Remove labels from an issue",
|
||||
func() error {
|
||||
return CmdLabelsRemove(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdLabelsRemoveUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdLabelsRemoveUsage(cmd *kingpin.CmdClause, opts *LabelsRemoveOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Arg("ISSUE", "issue id to modify labels").Required().StringVar(&opts.Issue)
|
||||
cmd.Arg("LABEL", "label to remove from issue").Required().StringsVar(&opts.Labels)
|
||||
return nil
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,36 +6,37 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type LabelsSetOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdLabelsSetRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := LabelsSetOptions{}
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Set labels on an issue",
|
||||
func() error {
|
||||
return CmdLabelsSet(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdLabelsSetUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdLabelsSetUsage(cmd *kingpin.CmdClause, opts *LabelsSetOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
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
|
||||
@@ -1,31 +1,32 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type ListOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jira.SearchOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
}
|
||||
|
||||
func CmdListRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
func CmdListRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := ListOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("list"),
|
||||
},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Prints list of issues for given search criteria",
|
||||
func() error {
|
||||
return CmdList(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.MaxResults == 0 {
|
||||
opts.MaxResults = 500
|
||||
}
|
||||
@@ -41,10 +42,10 @@ func CmdListRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry
|
||||
}
|
||||
|
||||
func CmdListUsage(cmd *kingpin.CmdClause, opts *ListOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
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)
|
||||
@@ -64,5 +65,5 @@ func CmdList(o *oreo.Client, opts *ListOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return runTemplate(opts.Template.Value, data, nil)
|
||||
return jiracli.RunTemplate(opts.Template.Value, data, nil)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -7,20 +7,21 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
"github.com/mgutz/ansi"
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdLoginRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
opts := GlobalOptions{}
|
||||
return &CommandRegistryEntry{
|
||||
func CmdLoginRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := jiracli.GlobalOptions{}
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Attempt to login into jira server",
|
||||
func() error {
|
||||
return CmdLogin(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
return GlobalUsage(cmd, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return jiracli.GlobalUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -44,7 +45,7 @@ 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 *GlobalOptions) error {
|
||||
func CmdLogin(o *oreo.Client, opts *jiracli.GlobalOptions) error {
|
||||
ua := o.WithoutRedirect().WithRetries(0).WithoutCallbacks().WithPostCallback(authCallback)
|
||||
for {
|
||||
if session, err := jira.GetSession(o, opts.Endpoint.Value); err != nil {
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,26 +6,27 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
"github.com/mgutz/ansi"
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdLogoutRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
opts := GlobalOptions{}
|
||||
return &CommandRegistryEntry{
|
||||
func CmdLogoutRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := jiracli.GlobalOptions{}
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Deactivate sesssion with Jira server",
|
||||
func() error {
|
||||
return CmdLogout(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
return GlobalUsage(cmd, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return jiracli.GlobalUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// CmdLogout will attempt to terminate an active Jira session
|
||||
func CmdLogout(o *oreo.Client, opts *GlobalOptions) error {
|
||||
func CmdLogout(o *oreo.Client, opts *jiracli.GlobalOptions) error {
|
||||
ua := o.WithoutRedirect().WithRetries(0).WithoutCallbacks()
|
||||
err := jira.DeleteSession(ua, opts.Endpoint.Value)
|
||||
if err == nil {
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,38 +6,39 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type RankOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdRankRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := RankOptions{}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Mark issues as blocker",
|
||||
func() error {
|
||||
return CmdRank(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdRankUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdRankUsage(cmd *kingpin.CmdClause, opts *RankOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
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)
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
@@ -10,30 +10,31 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type RequestOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdRequestRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := RequestOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("request"),
|
||||
},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Open issue in requestr",
|
||||
func() error {
|
||||
return CmdRequest(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.Method == "" {
|
||||
opts.Method = "GET"
|
||||
}
|
||||
@@ -43,7 +44,7 @@ func CmdRequestRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEn
|
||||
}
|
||||
|
||||
func CmdRequestUsage(cmd *kingpin.CmdClause, opts *RequestOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
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")
|
||||
@@ -89,5 +90,5 @@ func CmdRequest(o *oreo.Client, opts *RequestOptions) error {
|
||||
return fmt.Errorf("JSON Parse Error: %s from %q", err, content)
|
||||
}
|
||||
|
||||
return runTemplate(opts.Template.Value, &data, nil)
|
||||
return jiracli.RunTemplate(opts.Template.Value, &data, nil)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,13 +6,14 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type SubtaskOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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"`
|
||||
@@ -20,21 +21,21 @@ type SubtaskOptions struct {
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdSubtaskRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
func CmdSubtaskRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := SubtaskOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("subtask"),
|
||||
},
|
||||
Overrides: map[string]string{},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Subtask issue",
|
||||
func() error {
|
||||
return CmdSubtask(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.IssueType == "" {
|
||||
opts.IssueType = "Sub-task"
|
||||
}
|
||||
@@ -44,16 +45,16 @@ func CmdSubtaskRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEn
|
||||
}
|
||||
|
||||
func CmdSubtaskUsage(cmd *kingpin.CmdClause, opts *SubtaskOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
EditorUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
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 {
|
||||
opts.Overrides["comment"] = flagValue(ctx, "comment")
|
||||
opts.Overrides["comment"] = jiracli.FlagValue(ctx, "comment")
|
||||
return nil
|
||||
}).String()
|
||||
cmd.Flag("override", "Set issue property").Short('o').StringMapVar(&opts.Overrides)
|
||||
@@ -101,7 +102,7 @@ func CmdSubtask(o *oreo.Client, opts *SubtaskOptions) error {
|
||||
input.Overrides["user"] = opts.User.Value
|
||||
|
||||
var issueResp *jiradata.IssueCreateResponse
|
||||
err = editLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
err = jiracli.EditLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
issueResp, err = jira.CreateIssue(o, opts.Endpoint.Value, &issueUpdate)
|
||||
return err
|
||||
})
|
||||
@@ -1,32 +1,33 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdTakeRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
func CmdTakeRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := AssignOptions{}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Assign issue to yourself",
|
||||
func() error {
|
||||
opts.Assignee = opts.User.Value
|
||||
return CmdAssign(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdAssignUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdTakeUsage(cmd *kingpin.CmdClause, opts *AssignOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Arg("ISSUE", "issue to assign").Required().StringVar(&opts.Issue)
|
||||
return nil
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -7,22 +7,23 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type TransitionOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdTransitionRegistry(fig *figtree.FigTree, o *oreo.Client, transition string) *jiracli.CommandRegistryEntry {
|
||||
opts := TransitionOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("transition"),
|
||||
},
|
||||
Overrides: map[string]string{},
|
||||
@@ -34,13 +35,13 @@ func CmdTransitionRegistry(fig *figtree.FigTree, o *oreo.Client, transition stri
|
||||
opts.SkipEditing = figtree.NewBoolOption(true)
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
help,
|
||||
func() error {
|
||||
return CmdTransition(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.Transition == "" {
|
||||
opts.Transition = transition
|
||||
}
|
||||
@@ -50,14 +51,14 @@ func CmdTransitionRegistry(fig *figtree.FigTree, o *oreo.Client, transition stri
|
||||
}
|
||||
|
||||
func CmdTransitionUsage(cmd *kingpin.CmdClause, opts *TransitionOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
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"] = flagValue(ctx, "comment")
|
||||
opts.Overrides["comment"] = jiracli.FlagValue(ctx, "comment")
|
||||
return nil
|
||||
}).String()
|
||||
cmd.Flag("override", "Set issue property").Short('o').StringMapVar(&opts.Overrides)
|
||||
@@ -72,12 +73,12 @@ func CmdTransitionUsage(cmd *kingpin.CmdClause, opts *TransitionOptions) error {
|
||||
func CmdTransition(o *oreo.Client, opts *TransitionOptions) error {
|
||||
issueData, err := jira.GetIssue(o, opts.Endpoint.Value, opts.Issue, nil)
|
||||
if err != nil {
|
||||
return cliError(err)
|
||||
return jiracli.CliError(err)
|
||||
}
|
||||
|
||||
meta, err := jira.GetIssueTransitions(o, opts.Endpoint.Value, opts.Issue)
|
||||
if err != nil {
|
||||
return cliError(err)
|
||||
return jiracli.CliError(err)
|
||||
}
|
||||
transMeta := meta.Transitions.Find(opts.Transition)
|
||||
|
||||
@@ -89,10 +90,10 @@ func CmdTransition(o *oreo.Client, opts *TransitionOptions) error {
|
||||
|
||||
if status, ok := issueData.Fields["status"].(map[string]interface{}); ok {
|
||||
if name, ok := status["name"].(string); ok {
|
||||
return cliError(fmt.Errorf("Invalid Transition %q from %q, Available: %s", opts.Transition, name, strings.Join(possible, ", ")))
|
||||
return jiracli.CliError(fmt.Errorf("Invalid Transition %q from %q, Available: %s", opts.Transition, name, strings.Join(possible, ", ")))
|
||||
}
|
||||
}
|
||||
return cliError(fmt.Errorf("No valid transition found matching %s", opts.Transition))
|
||||
return jiracli.CliError(fmt.Errorf("No valid transition found matching %s", opts.Transition))
|
||||
}
|
||||
|
||||
// need to default the Resolution, usually Fixed works but sometime need Done
|
||||
@@ -127,11 +128,11 @@ func CmdTransition(o *oreo.Client, opts *TransitionOptions) error {
|
||||
Transition: transMeta,
|
||||
Overrides: opts.Overrides,
|
||||
}
|
||||
err = editLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
err = jiracli.EditLoop(&opts.GlobalOptions, &input, &issueUpdate, func() error {
|
||||
return jira.TransitionIssue(o, opts.Endpoint.Value, opts.Issue, &issueUpdate)
|
||||
})
|
||||
if err != nil {
|
||||
return cliError(err)
|
||||
return jiracli.CliError(err)
|
||||
}
|
||||
fmt.Printf("OK %s %s/browse/%s\n", issueData.Key, opts.Endpoint.Value, issueData.Key)
|
||||
|
||||
@@ -1,42 +1,43 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type TransitionsOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdTransitionsRegistry(fig *figtree.FigTree, o *oreo.Client, defaultTemplate string) *CommandRegistryEntry {
|
||||
func CmdTransitionsRegistry(fig *figtree.FigTree, o *oreo.Client, defaultTemplate string) *jiracli.CommandRegistryEntry {
|
||||
opts := TransitionsOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption(defaultTemplate),
|
||||
},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"List valid issue transitions",
|
||||
func() error {
|
||||
return CmdTransitions(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdTransitionsUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdTransitionsUsage(cmd *kingpin.CmdClause, opts *TransitionsOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Arg("ISSUE", "issue to list valid transitions").Required().StringVar(&opts.Issue)
|
||||
return nil
|
||||
}
|
||||
@@ -47,7 +48,7 @@ func CmdTransitions(o *oreo.Client, opts *TransitionsOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := runTemplate(opts.Template.Value, editMeta, nil); err != nil {
|
||||
if err := jiracli.RunTemplate(opts.Template.Value, editMeta, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
if opts.Browse.Value {
|
||||
@@ -1,31 +1,32 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdUnassignRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
func CmdUnassignRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := AssignOptions{}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Unassign an issue",
|
||||
func() error {
|
||||
return CmdAssign(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdAssignUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdUnassignUsage(cmd *kingpin.CmdClause, opts *AssignOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Arg("ISSUE", "issue to unassign").Required().StringVar(&opts.Issue)
|
||||
return nil
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -8,22 +8,22 @@ import (
|
||||
"path"
|
||||
|
||||
"github.com/coryb/figtree"
|
||||
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func CmdUnexportTemplatesRegistry(fig *figtree.FigTree) *CommandRegistryEntry {
|
||||
func CmdUnexportTemplatesRegistry(fig *figtree.FigTree) *jiracli.CommandRegistryEntry {
|
||||
opts := ExportTemplatesOptions{}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Remove unmodified exported templates",
|
||||
func() error {
|
||||
return CmdUnexportTemplates(&opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.Dir != "" {
|
||||
opts.Dir = fmt.Sprintf("%s/.jira.d/templates", Homedir())
|
||||
opts.Dir = fmt.Sprintf("%s/.jira.d/templates", jiracli.Homedir())
|
||||
}
|
||||
|
||||
return CmdExportTemplatesUsage(cmd, &opts)
|
||||
@@ -33,7 +33,7 @@ func CmdUnexportTemplatesRegistry(fig *figtree.FigTree) *CommandRegistryEntry {
|
||||
|
||||
// CmdUnexportTemplates will remove unmodified templates from export directory
|
||||
func CmdUnexportTemplates(opts *ExportTemplatesOptions) error {
|
||||
for name, template := range allTemplates {
|
||||
for name, template := range jiracli.AllTemplates {
|
||||
if opts.Template != "" && opts.Template != name {
|
||||
continue
|
||||
}
|
||||
@@ -1,43 +1,44 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type ViewOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdViewRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := ViewOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("view"),
|
||||
},
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Prints issue details",
|
||||
func() error {
|
||||
return CmdView(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdViewUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdViewUsage(cmd *kingpin.CmdClause, opts *ViewOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
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)
|
||||
@@ -51,7 +52,7 @@ func CmdView(o *oreo.Client, opts *ViewOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := runTemplate(opts.Template.Value, data, nil); err != nil {
|
||||
if err := jiracli.RunTemplate(opts.Template.Value, data, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
if opts.Browse.Value {
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,7 +6,8 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
@@ -18,34 +19,34 @@ const (
|
||||
)
|
||||
|
||||
type VoteOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdVoteRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := VoteOptions{
|
||||
GlobalOptions: GlobalOptions{},
|
||||
GlobalOptions: jiracli.GlobalOptions{},
|
||||
Action: VoteUP,
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Vote up/down an issue",
|
||||
func() error {
|
||||
return CmdVote(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdVoteUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdVoteUsage(cmd *kingpin.CmdClause, opts *VoteOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Flag("down", "downvote the issue").Short('d').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Action = VoteDown
|
||||
return nil
|
||||
@@ -1,4 +1,4 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,7 +6,8 @@ import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
@@ -18,35 +19,35 @@ const (
|
||||
)
|
||||
|
||||
type WatchOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdWatchRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := WatchOptions{
|
||||
GlobalOptions: GlobalOptions{},
|
||||
GlobalOptions: jiracli.GlobalOptions{},
|
||||
Action: WatcherAdd,
|
||||
}
|
||||
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Add/Remove watcher to issue",
|
||||
func() error {
|
||||
return CmdWatch(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdWatchUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdWatchUsage(cmd *kingpin.CmdClause, opts *WatchOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Flag("remove", "remove watcher from issue").Short('r').PreAction(func(ctx *kingpin.ParseContext) error {
|
||||
opts.Action = WatcherRemove
|
||||
return nil
|
||||
@@ -1,44 +1,45 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type WorklogAddOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `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) *CommandRegistryEntry {
|
||||
func CmdWorklogAddRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := WorklogAddOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("worklog"),
|
||||
},
|
||||
}
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Add a worklog to an issue",
|
||||
func() error {
|
||||
return CmdWorklogAdd(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdWorklogAddUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdWorklogAddUsage(cmd *kingpin.CmdClause, opts *WorklogAddOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
EditorUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.EditorUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
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,7 +51,7 @@ func CmdWorklogAddUsage(cmd *kingpin.CmdClause, opts *WorklogAddOptions) error {
|
||||
// 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 := editLoop(&opts.GlobalOptions, &opts.Worklog, &opts.Worklog, func() error {
|
||||
err := jiracli.EditLoop(&opts.GlobalOptions, &opts.Worklog, &opts.Worklog, func() error {
|
||||
_, err := jira.AddIssueWorklog(o, opts.Endpoint.Value, opts.Issue, opts)
|
||||
return err
|
||||
})
|
||||
@@ -1,41 +1,42 @@
|
||||
package jiracli
|
||||
package jiracmd
|
||||
|
||||
import (
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type WorklogListOptions struct {
|
||||
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
jiracli.GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
|
||||
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
|
||||
}
|
||||
|
||||
func CmdWorklogListRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
|
||||
func CmdWorklogListRegistry(fig *figtree.FigTree, o *oreo.Client) *jiracli.CommandRegistryEntry {
|
||||
opts := WorklogListOptions{
|
||||
GlobalOptions: GlobalOptions{
|
||||
GlobalOptions: jiracli.GlobalOptions{
|
||||
Template: figtree.NewStringOption("worklogs"),
|
||||
},
|
||||
}
|
||||
return &CommandRegistryEntry{
|
||||
return &jiracli.CommandRegistryEntry{
|
||||
"Prints the worklog data for given issue",
|
||||
func() error {
|
||||
return CmdWorklogList(o, &opts)
|
||||
},
|
||||
func(cmd *kingpin.CmdClause) error {
|
||||
LoadConfigs(cmd, fig, &opts)
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
return CmdWorklogListUsage(cmd, &opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CmdWorklogListUsage(cmd *kingpin.CmdClause, opts *WorklogListOptions) error {
|
||||
if err := GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
if err := jiracli.GlobalUsage(cmd, &opts.GlobalOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.BrowseUsage(cmd, &opts.GlobalOptions)
|
||||
jiracli.TemplateUsage(cmd, &opts.GlobalOptions)
|
||||
cmd.Arg("ISSUE", "issue id to fetch worklogs").Required().StringVar(&opts.Issue)
|
||||
return nil
|
||||
}
|
||||
@@ -46,7 +47,7 @@ func CmdWorklogList(o *oreo.Client, opts *WorklogListOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := runTemplate(opts.Template.Value, data, nil); err != nil {
|
||||
if err := jiracli.RunTemplate(opts.Template.Value, data, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
if opts.Browse.Value {
|
||||
Reference in New Issue
Block a user