Skip to content

Commit

Permalink
set yaml/json tags for option structs
Browse files Browse the repository at this point in the history
  • Loading branch information
coryb committed Aug 28, 2017
1 parent c89f11d commit f52d2c4
Show file tree
Hide file tree
Showing 30 changed files with 116 additions and 122 deletions.
6 changes: 3 additions & 3 deletions jiracli/assign.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
)

type AssignOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Issue string
Assignee string
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 {
Expand Down
8 changes: 4 additions & 4 deletions jiracli/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
)

type BlockOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
jiradata.LinkIssueRequest `yaml:",inline" figtree:",inline"`
Blocker string
Issue string
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
jiradata.LinkIssueRequest `yaml:",inline" json:",inline" figtree:",inline"`
Blocker string `yaml:"blocker,omitempty" json:"blocker,omitempty"`
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}

func CmdBlockRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
Expand Down
4 changes: 2 additions & 2 deletions jiracli/browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

type BrowseOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Issue string
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}

func CmdBrowseRegistry(fig *figtree.FigTree) *CommandRegistryEntry {
Expand Down
17 changes: 0 additions & 17 deletions jiracli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ import (

var log = logging.MustGetLogger("jira")

// type JiraCli struct {
// jira.Jira `yaml:",inline"`
// ConfigDir string
// oreoAgent *oreo.Client
// }

type Exit struct {
Code int
}
Expand Down Expand Up @@ -60,17 +54,6 @@ type kingpinAppOrCommand interface {
GetCommand(string) *kingpin.CmdClause
}

// func New(configDir string) *JiraCli {
// agent := oreo.New().WithCookieFile(filepath.Join(homedir(), configDir, "cookies.js"))
// return &JiraCli{
// ConfigDir: configDir,
// Jira: jira.Jira{
// UA: agent,
// },
// oreoAgent: agent,
// }
// }

func Register(app *kingpin.Application, reg []CommandRegistry) {
for _, command := range reg {
copy := command
Expand Down
6 changes: 3 additions & 3 deletions jiracli/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
)

type CommentOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Overrides map[string]string
Issue string
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 {
Expand Down
4 changes: 2 additions & 2 deletions jiracli/componentAdd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
)

type ComponentAddOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
jiradata.Component `yaml:",inline" figtree:",inline"`
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
jiradata.Component `yaml:",inline" json:",inline" figtree:",inline"`
}

func CmdComponentAddRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
Expand Down
4 changes: 2 additions & 2 deletions jiracli/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

type ComponentsOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Project string
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
}

func CmdComponentsRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
Expand Down
10 changes: 5 additions & 5 deletions jiracli/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
)

type CreateOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
jiradata.IssueUpdate `yaml:",inline" figtree:",inline"`
Project string
IssueType string
Overrides map[string]string
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"`
Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"`
}

func CmdCreateRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
Expand Down
2 changes: 1 addition & 1 deletion jiracli/createmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

type CreateMetaOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
IssueType string `yaml:"issuetype,omitempty" json:"issuetype,omitempty"`
}
Expand Down
8 changes: 4 additions & 4 deletions jiracli/dup.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
)

type DupOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
jiradata.LinkIssueRequest `yaml:",inline" figtree:",inline"`
Duplicate string
Issue string
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 {
Expand Down
10 changes: 5 additions & 5 deletions jiracli/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
)

type EditOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
jiradata.IssueUpdate `yaml:",inline" figtree:",inline"`
jira.SearchOptions `yaml:",inline" figtree:",inline"`
Overrides map[string]string
Issue string
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 {
Expand Down
4 changes: 2 additions & 2 deletions jiracli/editmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

type EditMetaOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Issue string
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}

func CmdEditMetaRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
Expand Down
11 changes: 6 additions & 5 deletions jiracli/exportTemplates.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import (
)

type ExportTemplatesOptions struct {
Template string
Dir string
Template string `yaml:"template,omitempty" json:"template,omitempty"`
Dir string `yaml:"dir,omitempty" json:"dir,omitempty"`
}

func CmdExportTemplatesRegistry(fig *figtree.FigTree) *CommandRegistryEntry {
opts := ExportTemplatesOptions{
Dir: fmt.Sprintf("%s/.jira.d/templates", Homedir()),
}
opts := ExportTemplatesOptions{}

return &CommandRegistryEntry{
"Export templates for customizations",
Expand All @@ -27,6 +25,9 @@ func CmdExportTemplatesRegistry(fig *figtree.FigTree) *CommandRegistryEntry {
},
func(cmd *kingpin.CmdClause) error {
LoadConfigs(cmd, fig, &opts)
if opts.Dir == "" {
opts.Dir = fmt.Sprintf("%s/.jira.d/templates", Homedir())
}
return CmdExportTemplatesUsage(cmd, &opts)
},
}
Expand Down
6 changes: 3 additions & 3 deletions jiracli/issuelink.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
)

type IssueLinkOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
jiradata.LinkIssueRequest `yaml:",inline" figtree:",inline"`
LinkType string
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 {
Expand Down
4 changes: 2 additions & 2 deletions jiracli/issuetypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

type IssueTypesOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Project string
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
}

func CmdIssueTypesRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
Expand Down
6 changes: 3 additions & 3 deletions jiracli/labelsAdd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
)

type LabelsAddOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Issue string
Labels []string
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 {
Expand Down
6 changes: 3 additions & 3 deletions jiracli/labelsRemove.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
)

type LabelsRemoveOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Issue string
Labels []string
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 {
Expand Down
6 changes: 3 additions & 3 deletions jiracli/labelsSet.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
)

type LabelsSetOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Issue string
Labels []string
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 {
Expand Down
18 changes: 11 additions & 7 deletions jiracli/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@ import (
)

type ListOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
jira.SearchOptions `yaml:",inline" figtree:",inline"`
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
jira.SearchOptions `yaml:",inline" json:",inline" figtree:",inline"`
}

func CmdListRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
opts := ListOptions{
GlobalOptions: GlobalOptions{
Template: figtree.NewStringOption("list"),
},
SearchOptions: jira.SearchOptions{
MaxResults: 500,
QueryFields: "assignee,created,priority,reporter,status,summary,updated",
Sort: "priority asc, key",
},
}

return &CommandRegistryEntry{
Expand All @@ -31,6 +26,15 @@ func CmdListRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry
},
func(cmd *kingpin.CmdClause) error {
LoadConfigs(cmd, fig, &opts)
if opts.MaxResults == 0 {
opts.MaxResults = 500
}
if opts.QueryFields == "" {
opts.QueryFields = "assignee,created,priority,reporter,status,summary,updated"
}
if opts.Sort == "" {
opts.Sort = "priority asc, key"
}
return CmdListUsage(cmd, &opts)
},
}
Expand Down
12 changes: 5 additions & 7 deletions jiracli/rank.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ import (
)

type RankOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
First string
Second string
Order string
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 {
opts := RankOptions{
GlobalOptions: GlobalOptions{},
}
opts := RankOptions{}

return &CommandRegistryEntry{
"Mark issues as blocker",
Expand Down
12 changes: 7 additions & 5 deletions jiracli/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ import (
)

type RequestOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Method string
URI string
Data string
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 {
opts := RequestOptions{
GlobalOptions: GlobalOptions{
Template: figtree.NewStringOption("request"),
},
Method: "GET",
}

return &CommandRegistryEntry{
Expand All @@ -35,6 +34,9 @@ func CmdRequestRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEn
},
func(cmd *kingpin.CmdClause) error {
LoadConfigs(cmd, fig, &opts)
if opts.Method == "" {
opts.Method = "GET"
}
return CmdRequestUsage(cmd, &opts)
},
}
Expand Down
16 changes: 9 additions & 7 deletions jiracli/subtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ import (
)

type SubtaskOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
jiradata.IssueUpdate `yaml:",inline" figtree:",inline"`
Project string
IssueType string
Overrides map[string]string
Issue string
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"`
Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"`
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}

func CmdSubtaskRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {
opts := SubtaskOptions{
GlobalOptions: GlobalOptions{
Template: figtree.NewStringOption("subtask"),
},
IssueType: "Sub-task",
Overrides: map[string]string{},
}

Expand All @@ -36,6 +35,9 @@ func CmdSubtaskRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEn
},
func(cmd *kingpin.CmdClause) error {
LoadConfigs(cmd, fig, &opts)
if opts.IssueType == "" {
opts.IssueType = "Sub-task"
}
return CmdSubtaskUsage(cmd, &opts)
},
}
Expand Down
Loading

0 comments on commit f52d2c4

Please sign in to comment.