refactor to allow for --insecure and --unixproxy arguments

This commit is contained in:
Cory Bennett
2017-09-04 17:53:01 -07:00
parent 21920c5888
commit c0358eb67c
38 changed files with 146 additions and 120 deletions
+44 -44
View File
@@ -107,178 +107,178 @@ func main() {
registry := []jiracli.CommandRegistry{
jiracli.CommandRegistry{
Command: "login",
Entry: jiracmd.CmdLoginRegistry(o),
Entry: jiracmd.CmdLoginRegistry(),
},
jiracli.CommandRegistry{
Command: "logout",
Entry: jiracmd.CmdLogoutRegistry(o),
Entry: jiracmd.CmdLogoutRegistry(),
},
jiracli.CommandRegistry{
Command: "list",
Aliases: []string{"ls"},
Entry: jiracmd.CmdListRegistry(o),
Entry: jiracmd.CmdListRegistry(),
},
jiracli.CommandRegistry{
Command: "view",
Entry: jiracmd.CmdViewRegistry(o),
Entry: jiracmd.CmdViewRegistry(),
},
jiracli.CommandRegistry{
Command: "create",
Entry: jiracmd.CmdCreateRegistry(o),
Entry: jiracmd.CmdCreateRegistry(),
},
jiracli.CommandRegistry{
Command: "edit",
Entry: jiracmd.CmdEditRegistry(o),
Entry: jiracmd.CmdEditRegistry(),
},
jiracli.CommandRegistry{
Command: "comment",
Entry: jiracmd.CmdCommentRegistry(o),
Entry: jiracmd.CmdCommentRegistry(),
},
jiracli.CommandRegistry{
Command: "worklog list",
Entry: jiracmd.CmdWorklogListRegistry(o),
Entry: jiracmd.CmdWorklogListRegistry(),
Default: true,
},
jiracli.CommandRegistry{
Command: "worklog add",
Entry: jiracmd.CmdWorklogAddRegistry(o),
Entry: jiracmd.CmdWorklogAddRegistry(),
},
jiracli.CommandRegistry{
Command: "fields",
Entry: jiracmd.CmdFieldsRegistry(o),
Entry: jiracmd.CmdFieldsRegistry(),
},
jiracli.CommandRegistry{
Command: "createmeta",
Entry: jiracmd.CmdCreateMetaRegistry(o),
Entry: jiracmd.CmdCreateMetaRegistry(),
},
jiracli.CommandRegistry{
Command: "editmeta",
Entry: jiracmd.CmdEditMetaRegistry(o),
Entry: jiracmd.CmdEditMetaRegistry(),
},
jiracli.CommandRegistry{
Command: "subtask",
Entry: jiracmd.CmdSubtaskRegistry(o),
Entry: jiracmd.CmdSubtaskRegistry(),
},
jiracli.CommandRegistry{
Command: "dup",
Entry: jiracmd.CmdDupRegistry(o),
Entry: jiracmd.CmdDupRegistry(),
},
jiracli.CommandRegistry{
Command: "block",
Entry: jiracmd.CmdBlockRegistry(o),
Entry: jiracmd.CmdBlockRegistry(),
},
jiracli.CommandRegistry{
Command: "issuelink",
Entry: jiracmd.CmdIssueLinkRegistry(o),
Entry: jiracmd.CmdIssueLinkRegistry(),
},
jiracli.CommandRegistry{
Command: "issuelinktypes",
Entry: jiracmd.CmdIssueLinkTypesRegistry(o),
Entry: jiracmd.CmdIssueLinkTypesRegistry(),
},
jiracli.CommandRegistry{
Command: "transition",
Aliases: []string{"trans"},
Entry: jiracmd.CmdTransitionRegistry(o, ""),
Entry: jiracmd.CmdTransitionRegistry(""),
},
jiracli.CommandRegistry{
Command: "transitions",
Entry: jiracmd.CmdTransitionsRegistry(o, "transitions"),
Entry: jiracmd.CmdTransitionsRegistry("transitions"),
},
jiracli.CommandRegistry{
Command: "transmeta",
Entry: jiracmd.CmdTransitionsRegistry(o, "debug"),
Entry: jiracmd.CmdTransitionsRegistry("debug"),
},
jiracli.CommandRegistry{
Command: "close",
Entry: jiracmd.CmdTransitionRegistry(o, "close"),
Entry: jiracmd.CmdTransitionRegistry("close"),
},
jiracli.CommandRegistry{
Command: "acknowledge",
Aliases: []string{"ack"},
Entry: jiracmd.CmdTransitionRegistry(o, "acknowledge"),
Entry: jiracmd.CmdTransitionRegistry("acknowledge"),
},
jiracli.CommandRegistry{
Command: "reopen",
Entry: jiracmd.CmdTransitionRegistry(o, "reopen"),
Entry: jiracmd.CmdTransitionRegistry("reopen"),
},
jiracli.CommandRegistry{
Command: "resolve",
Entry: jiracmd.CmdTransitionRegistry(o, "resolve"),
Entry: jiracmd.CmdTransitionRegistry("resolve"),
},
jiracli.CommandRegistry{
Command: "start",
Entry: jiracmd.CmdTransitionRegistry(o, "start"),
Entry: jiracmd.CmdTransitionRegistry("start"),
},
jiracli.CommandRegistry{
Command: "stop",
Entry: jiracmd.CmdTransitionRegistry(o, "stop"),
Entry: jiracmd.CmdTransitionRegistry("stop"),
},
jiracli.CommandRegistry{
Command: "todo",
Entry: jiracmd.CmdTransitionRegistry(o, "To Do"),
Entry: jiracmd.CmdTransitionRegistry("To Do"),
},
jiracli.CommandRegistry{
Command: "backlog",
Entry: jiracmd.CmdTransitionRegistry(o, "Backlog"),
Entry: jiracmd.CmdTransitionRegistry("Backlog"),
},
jiracli.CommandRegistry{
Command: "done",
Entry: jiracmd.CmdTransitionRegistry(o, "Done"),
Entry: jiracmd.CmdTransitionRegistry("Done"),
},
jiracli.CommandRegistry{
Command: "in-progress",
Aliases: []string{"prog", "progress"},
Entry: jiracmd.CmdTransitionRegistry(o, "Progress"),
Entry: jiracmd.CmdTransitionRegistry("Progress"),
},
jiracli.CommandRegistry{
Command: "vote",
Entry: jiracmd.CmdVoteRegistry(o),
Entry: jiracmd.CmdVoteRegistry(),
},
jiracli.CommandRegistry{
Command: "rank",
Entry: jiracmd.CmdRankRegistry(o),
Entry: jiracmd.CmdRankRegistry(),
},
jiracli.CommandRegistry{
Command: "watch",
Entry: jiracmd.CmdWatchRegistry(o),
Entry: jiracmd.CmdWatchRegistry(),
},
jiracli.CommandRegistry{
Command: "labels add",
Entry: jiracmd.CmdLabelsAddRegistry(o),
Entry: jiracmd.CmdLabelsAddRegistry(),
},
jiracli.CommandRegistry{
Command: "labels set",
Entry: jiracmd.CmdLabelsSetRegistry(o),
Entry: jiracmd.CmdLabelsSetRegistry(),
},
jiracli.CommandRegistry{
Command: "labels remove",
Entry: jiracmd.CmdLabelsRemoveRegistry(o),
Entry: jiracmd.CmdLabelsRemoveRegistry(),
Aliases: []string{"rm"},
},
jiracli.CommandRegistry{
Command: "take",
Entry: jiracmd.CmdTakeRegistry(o),
Entry: jiracmd.CmdTakeRegistry(),
},
jiracli.CommandRegistry{
Command: "assign",
Entry: jiracmd.CmdAssignRegistry(o),
Entry: jiracmd.CmdAssignRegistry(),
Aliases: []string{"give"},
},
jiracli.CommandRegistry{
Command: "unassign",
Entry: jiracmd.CmdUnassignRegistry(o),
Entry: jiracmd.CmdUnassignRegistry(),
},
jiracli.CommandRegistry{
Command: "component add",
Entry: jiracmd.CmdComponentAddRegistry(o),
Entry: jiracmd.CmdComponentAddRegistry(),
},
jiracli.CommandRegistry{
Command: "components",
Entry: jiracmd.CmdComponentsRegistry(o),
Entry: jiracmd.CmdComponentsRegistry(),
},
jiracli.CommandRegistry{
Command: "issuetypes",
Entry: jiracmd.CmdIssueTypesRegistry(o),
Entry: jiracmd.CmdIssueTypesRegistry(),
},
jiracli.CommandRegistry{
Command: "export-templates",
@@ -295,12 +295,12 @@ func main() {
},
jiracli.CommandRegistry{
Command: "request",
Entry: jiracmd.CmdRequestRegistry(o),
Entry: jiracmd.CmdRequestRegistry(),
Aliases: []string{"req"},
},
}
jiracli.Register(app, fig, registry)
jiracli.Register(app, o, fig, registry)
// register custom commands
data := struct {
+26 -3
View File
@@ -2,9 +2,11 @@ package jiracli
import (
"bytes"
"crypto/tls"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"os/exec"
"reflect"
@@ -12,6 +14,7 @@ import (
"github.com/AlecAivazis/survey"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/jinzhu/copier"
shellquote "github.com/kballard/go-shellquote"
kingpin "gopkg.in/alecthomas/kingpin.v2"
@@ -29,6 +32,8 @@ 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"`
UnixProxy figtree.StringOption `yaml:"unixproxy,omitempty" json:"unixproxy,omitempty"`
Insecure figtree.BoolOption `yaml:"insecure,omitempty" json:"insecure,omitempty"`
}
type CommonOptions struct {
@@ -41,7 +46,7 @@ type CommonOptions struct {
type CommandRegistryEntry struct {
Help string
UsageFunc func(*figtree.FigTree, *kingpin.CmdClause) error
ExecuteFunc func(*GlobalOptions) error
ExecuteFunc func(*oreo.Client, *GlobalOptions) error
}
type CommandRegistry struct {
@@ -57,12 +62,30 @@ type kingpinAppOrCommand interface {
GetCommand(string) *kingpin.CmdClause
}
func Register(app *kingpin.Application, fig *figtree.FigTree, reg []CommandRegistry) {
func Register(app *kingpin.Application, o *oreo.Client, 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)
app.Flag("unixproxy", "Path for a unix-socket proxy").SetValue(&globals.UnixProxy)
app.Flag("insecure", "Disable TLS certificate verification").Short('k').SetValue(&globals.Insecure)
app.PreAction(func(_ *kingpin.ParseContext) error {
if globals.Insecure.Value {
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
}
o = o.WithTransport(transport)
}
if globals.UnixProxy.Value != "" {
o = o.WithTransport(unixProxy(globals.UnixProxy.Value))
}
return nil
})
for _, command := range reg {
copy := command
@@ -93,7 +116,7 @@ func Register(app *kingpin.Application, fig *figtree.FigTree, reg []CommandRegis
cmd.Action(
func(_ *kingpin.ParseContext) error {
return copy.Entry.ExecuteFunc(&globals)
return copy.Entry.ExecuteFunc(o, &globals)
},
)
}
+6 -6
View File
@@ -8,11 +8,11 @@ import (
"time"
)
type Transport struct {
type transport struct {
shadow *http.Transport
}
func NewUnixProxyTransport(path string) *Transport {
func newUnixProxyTransport(path string) *transport {
dial := func(network, addr string) (net.Conn, error) {
return net.Dial("unix", path)
}
@@ -25,14 +25,14 @@ func NewUnixProxyTransport(path string) *Transport {
ExpectContinueTimeout: 10 * time.Second,
}
return &Transport{shadow}
return &transport{shadow}
}
func UnixProxy(path string) *Transport {
return NewUnixProxyTransport(os.ExpandEnv(path))
func unixProxy(path string) *transport {
return newUnixProxyTransport(os.ExpandEnv(path))
}
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
req2 := *req
url2 := *req.URL
req2.URL = &url2
+2 -2
View File
@@ -16,7 +16,7 @@ type AssignOptions struct {
Assignee string `yaml:"assignee,omitempty" json:"assignee,omitempty"`
}
func CmdAssignRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdAssignRegistry() *jiracli.CommandRegistryEntry {
opts := AssignOptions{}
return &jiracli.CommandRegistryEntry{
@@ -25,7 +25,7 @@ func CmdAssignRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdAssignUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdAssign(o, globals, &opts)
},
}
+2 -2
View File
@@ -17,7 +17,7 @@ type BlockOptions struct {
jiradata.LinkIssueRequest `yaml:",inline" json:",inline" figtree:",inline"`
}
func CmdBlockRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdBlockRegistry() *jiracli.CommandRegistryEntry {
opts := BlockOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("edit"),
@@ -37,7 +37,7 @@ func CmdBlockRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdBlockUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdBlock(o, globals, &opts)
},
}
+2 -1
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/pkg/browser"
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
@@ -18,7 +19,7 @@ func CmdBrowseRegistry() *jiracli.CommandRegistryEntry {
cmd.Arg("ISSUE", "Issue to browse to").Required().StringVar(&issue)
return nil
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdBrowse(globals, issue)
},
}
+2 -2
View File
@@ -18,7 +18,7 @@ type CommentOptions struct {
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdCommentRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdCommentRegistry() *jiracli.CommandRegistryEntry {
opts := CommentOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("comment"),
@@ -32,7 +32,7 @@ func CmdCommentRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdCommentUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdComment(o, globals, &opts)
},
}
+2 -2
View File
@@ -17,7 +17,7 @@ type ComponentAddOptions struct {
jiradata.Component `yaml:",inline" json:",inline" figtree:",inline"`
}
func CmdComponentAddRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdComponentAddRegistry() *jiracli.CommandRegistryEntry {
opts := ComponentAddOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("component-add"),
@@ -30,7 +30,7 @@ func CmdComponentAddRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdComponentAddUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdComponentAdd(o, globals, &opts)
},
}
+2 -2
View File
@@ -16,7 +16,7 @@ type ComponentsOptions struct {
Project string `yaml:"project,omitempty" json:"project,omitempty"`
}
func CmdComponentsRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdComponentsRegistry() *jiracli.CommandRegistryEntry {
opts := ComponentsOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("components"),
@@ -29,7 +29,7 @@ func CmdComponentsRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdComponentsUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdComponents(o, globals, &opts)
},
}
+2 -2
View File
@@ -23,7 +23,7 @@ type CreateOptions struct {
SaveFile string `yaml:"savefile,omitempty" json:"savefile,omitempty"`
}
func CmdCreateRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdCreateRegistry() *jiracli.CommandRegistryEntry {
opts := CreateOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("create"),
@@ -37,7 +37,7 @@ func CmdCreateRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdCreateUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdCreate(o, globals, &opts)
},
}
+2 -2
View File
@@ -14,7 +14,7 @@ type CreateMetaOptions struct {
IssueType string `yaml:"issuetype,omitempty" json:"issuetype,omitempty"`
}
func CmdCreateMetaRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdCreateMetaRegistry() *jiracli.CommandRegistryEntry {
opts := CreateMetaOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("createmeta"),
@@ -27,7 +27,7 @@ func CmdCreateMetaRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdCreateMetaUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdCreateMeta(o, globals, &opts)
},
}
+2 -2
View File
@@ -19,7 +19,7 @@ type DupOptions struct {
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdDupRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdDupRegistry() *jiracli.CommandRegistryEntry {
opts := DupOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("edit"),
@@ -39,7 +39,7 @@ func CmdDupRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdDupUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdDup(o, globals, &opts)
},
}
+2 -2
View File
@@ -20,7 +20,7 @@ type EditOptions struct {
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdEditRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdEditRegistry() *jiracli.CommandRegistryEntry {
opts := EditOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("edit"),
@@ -34,7 +34,7 @@ func CmdEditRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdEditUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdEdit(o, globals, &opts)
},
}
+2 -2
View File
@@ -13,7 +13,7 @@ type EditMetaOptions struct {
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdEditMetaRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdEditMetaRegistry() *jiracli.CommandRegistryEntry {
opts := EditMetaOptions{
CommonOptions: jiracli.CommonOptions{
@@ -27,7 +27,7 @@ func CmdEditMetaRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdEditMetaUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdEditMeta(o, globals, &opts)
},
}
+2 -1
View File
@@ -6,6 +6,7 @@ import (
"path"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
@@ -27,7 +28,7 @@ func CmdExportTemplatesRegistry() *jiracli.CommandRegistryEntry {
}
return CmdExportTemplatesUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdExportTemplates(&opts)
},
}
+2 -2
View File
@@ -8,7 +8,7 @@ import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
func CmdFieldsRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdFieldsRegistry() *jiracli.CommandRegistryEntry {
opts := jiracli.CommonOptions{
Template: figtree.NewStringOption("fields"),
}
@@ -19,7 +19,7 @@ func CmdFieldsRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.TemplateUsage(cmd, &opts)
return nil
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdFields(o, globals, &opts)
},
}
+2 -2
View File
@@ -18,7 +18,7 @@ type IssueLinkOptions struct {
LinkType string `yaml:"linktype,omitempty" json:"linktype,omitempty"`
}
func CmdIssueLinkRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdIssueLinkRegistry() *jiracli.CommandRegistryEntry {
opts := IssueLinkOptions{
LinkIssueRequest: jiradata.LinkIssueRequest{
Type: &jiradata.IssueLinkType{},
@@ -32,7 +32,7 @@ func CmdIssueLinkRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdIssueLinkUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdIssueLink(o, globals, &opts)
},
}
+2 -2
View File
@@ -8,7 +8,7 @@ import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
func CmdIssueLinkTypesRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdIssueLinkTypesRegistry() *jiracli.CommandRegistryEntry {
opts := jiracli.CommonOptions{
Template: figtree.NewStringOption("issuelinktypes"),
}
@@ -19,7 +19,7 @@ func CmdIssueLinkTypesRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdIssueLinkTypesUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdIssueLinkTypes(o, globals, &opts)
},
}
+2 -2
View File
@@ -16,7 +16,7 @@ type IssueTypesOptions struct {
Project string `yaml:"project,omitempty" json:"project,omitempty"`
}
func CmdIssueTypesRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdIssueTypesRegistry() *jiracli.CommandRegistryEntry {
opts := IssueTypesOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("issuetypes"),
@@ -29,7 +29,7 @@ func CmdIssueTypesRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdIssueTypesUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdIssueTypes(o, globals, &opts)
},
}
+2 -2
View File
@@ -18,7 +18,7 @@ type LabelsAddOptions struct {
Labels []string `yaml:"labels,omitempty" json:"labels,omitempty"`
}
func CmdLabelsAddRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdLabelsAddRegistry() *jiracli.CommandRegistryEntry {
opts := LabelsAddOptions{}
return &jiracli.CommandRegistryEntry{
"Add labels to an issue",
@@ -26,7 +26,7 @@ func CmdLabelsAddRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdLabelsAddUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdLabelsAdd(o, globals, &opts)
},
}
+2 -2
View File
@@ -18,7 +18,7 @@ type LabelsRemoveOptions struct {
Labels []string `yaml:"labels,omitempty" json:"labels,omitempty"`
}
func CmdLabelsRemoveRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdLabelsRemoveRegistry() *jiracli.CommandRegistryEntry {
opts := LabelsRemoveOptions{}
return &jiracli.CommandRegistryEntry{
"Remove labels from an issue",
@@ -26,7 +26,7 @@ func CmdLabelsRemoveRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdLabelsRemoveUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdLabelsRemove(o, globals, &opts)
},
}
+2 -2
View File
@@ -18,7 +18,7 @@ type LabelsSetOptions struct {
Labels []string `yaml:"labels,omitempty" json:"labels,omitempty"`
}
func CmdLabelsSetRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdLabelsSetRegistry() *jiracli.CommandRegistryEntry {
opts := LabelsSetOptions{}
return &jiracli.CommandRegistryEntry{
"Set labels on an issue",
@@ -26,7 +26,7 @@ func CmdLabelsSetRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdLabelsSetUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdLabelsSet(o, globals, &opts)
},
}
+2 -2
View File
@@ -13,7 +13,7 @@ type ListOptions struct {
jira.SearchOptions `yaml:",inline" json:",inline" figtree:",inline"`
}
func CmdListRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdListRegistry() *jiracli.CommandRegistryEntry {
opts := ListOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("list"),
@@ -35,7 +35,7 @@ func CmdListRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
}
return CmdListUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdList(o, globals, &opts)
},
}
+2 -2
View File
@@ -12,7 +12,7 @@ import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
func CmdLoginRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdLoginRegistry() *jiracli.CommandRegistryEntry {
opts := jiracli.CommonOptions{}
return &jiracli.CommandRegistryEntry{
"Attempt to login into jira server",
@@ -20,7 +20,7 @@ func CmdLoginRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return nil
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdLogin(o, globals, &opts)
},
}
+2 -2
View File
@@ -11,7 +11,7 @@ import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
func CmdLogoutRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdLogoutRegistry() *jiracli.CommandRegistryEntry {
opts := jiracli.CommonOptions{}
return &jiracli.CommandRegistryEntry{
"Deactivate sesssion with Jira server",
@@ -19,7 +19,7 @@ func CmdLogoutRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return nil
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdLogout(o, globals, &opts)
},
}
+2 -2
View File
@@ -19,7 +19,7 @@ type RankOptions struct {
Order string `yaml:"order,omitempty" json:"order,omitempty"`
}
func CmdRankRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdRankRegistry() *jiracli.CommandRegistryEntry {
opts := RankOptions{}
return &jiracli.CommandRegistryEntry{
@@ -28,7 +28,7 @@ func CmdRankRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdRankUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdRank(o, globals, &opts)
},
}
+2 -2
View File
@@ -21,7 +21,7 @@ type RequestOptions struct {
Data string `yaml:"data,omitempty" json:"data,omitempty"`
}
func CmdRequestRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdRequestRegistry() *jiracli.CommandRegistryEntry {
opts := RequestOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("request"),
@@ -37,7 +37,7 @@ func CmdRequestRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
}
return CmdRequestUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdRequest(o, globals, &opts)
},
}
+2 -2
View File
@@ -21,7 +21,7 @@ type SubtaskOptions struct {
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdSubtaskRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdSubtaskRegistry() *jiracli.CommandRegistryEntry {
opts := SubtaskOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("subtask"),
@@ -38,7 +38,7 @@ func CmdSubtaskRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
}
return CmdSubtaskUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdSubtask(o, globals, &opts)
},
}
+2 -2
View File
@@ -7,7 +7,7 @@ import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
func CmdTakeRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdTakeRegistry() *jiracli.CommandRegistryEntry {
opts := AssignOptions{}
return &jiracli.CommandRegistryEntry{
@@ -16,7 +16,7 @@ func CmdTakeRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdAssignUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
opts.Assignee = globals.User.Value
return CmdAssign(o, globals, &opts)
},
+2 -2
View File
@@ -21,7 +21,7 @@ type TransitionOptions struct {
Resolution string `yaml:"resolution,omitempty" json:"resolution,omitempty"`
}
func CmdTransitionRegistry(o *oreo.Client, transition string) *jiracli.CommandRegistryEntry {
func CmdTransitionRegistry(transition string) *jiracli.CommandRegistryEntry {
opts := TransitionOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("transition"),
@@ -44,7 +44,7 @@ func CmdTransitionRegistry(o *oreo.Client, transition string) *jiracli.CommandRe
}
return CmdTransitionUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdTransition(o, globals, &opts)
},
}
+2 -2
View File
@@ -13,7 +13,7 @@ type TransitionsOptions struct {
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdTransitionsRegistry(o *oreo.Client, defaultTemplate string) *jiracli.CommandRegistryEntry {
func CmdTransitionsRegistry(defaultTemplate string) *jiracli.CommandRegistryEntry {
opts := TransitionsOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption(defaultTemplate),
@@ -26,7 +26,7 @@ func CmdTransitionsRegistry(o *oreo.Client, defaultTemplate string) *jiracli.Com
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdTransitionsUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdTransitions(o, globals, &opts)
},
}
+2 -2
View File
@@ -7,7 +7,7 @@ import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
func CmdUnassignRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdUnassignRegistry() *jiracli.CommandRegistryEntry {
opts := AssignOptions{}
return &jiracli.CommandRegistryEntry{
@@ -16,7 +16,7 @@ func CmdUnassignRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdAssignUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdAssign(o, globals, &opts)
},
}
+2 -1
View File
@@ -8,6 +8,7 @@ import (
"path"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
@@ -25,7 +26,7 @@ func CmdUnexportTemplatesRegistry() *jiracli.CommandRegistryEntry {
return CmdExportTemplatesUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdUnexportTemplates(&opts)
},
}
+2 -2
View File
@@ -14,7 +14,7 @@ type ViewOptions struct {
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdViewRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdViewRegistry() *jiracli.CommandRegistryEntry {
opts := ViewOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("view"),
@@ -27,7 +27,7 @@ func CmdViewRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdViewUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdView(o, globals, &opts)
},
}
+2 -2
View File
@@ -24,7 +24,7 @@ type VoteOptions struct {
Action VoteAction `yaml:"-" json:"-"`
}
func CmdVoteRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdVoteRegistry() *jiracli.CommandRegistryEntry {
opts := VoteOptions{
CommonOptions: jiracli.CommonOptions{},
Action: VoteUP,
@@ -36,7 +36,7 @@ func CmdVoteRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdVoteUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdVote(o, globals, &opts)
},
}
+2 -2
View File
@@ -25,7 +25,7 @@ type WatchOptions struct {
Action WatchAction `yaml:"-" json:"-"`
}
func CmdWatchRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdWatchRegistry() *jiracli.CommandRegistryEntry {
opts := WatchOptions{
CommonOptions: jiracli.CommonOptions{},
Action: WatcherAdd,
@@ -37,7 +37,7 @@ func CmdWatchRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdWatchUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdWatch(o, globals, &opts)
},
}
+2 -2
View File
@@ -17,7 +17,7 @@ type WorklogAddOptions struct {
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdWorklogAddRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdWorklogAddRegistry() *jiracli.CommandRegistryEntry {
opts := WorklogAddOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("worklog"),
@@ -29,7 +29,7 @@ func CmdWorklogAddRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdWorklogAddUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdWorklogAdd(o, globals, &opts)
},
}
+2 -2
View File
@@ -14,7 +14,7 @@ type WorklogListOptions struct {
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdWorklogListRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
func CmdWorklogListRegistry() *jiracli.CommandRegistryEntry {
opts := WorklogListOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("worklogs"),
@@ -26,7 +26,7 @@ func CmdWorklogListRegistry(o *oreo.Client) *jiracli.CommandRegistryEntry {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdWorklogListUsage(cmd, &opts)
},
func(globals *jiracli.GlobalOptions) error {
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdWorklogList(o, globals, &opts)
},
}