set yaml/json tags for option structs

This commit is contained in:
Cory Bennett
2017-08-27 20:46:25 -07:00
parent c89f11d5b5
commit f52d2c472a
30 changed files with 116 additions and 122 deletions
+3 -3
View File
@@ -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 {
+4 -4
View File
@@ -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 {
+2 -2
View File
@@ -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 {
-17
View File
@@ -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
}
@@ -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
+3 -3
View File
@@ -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 {
+2 -2
View File
@@ -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 {
+2 -2
View File
@@ -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 {
+5 -5
View File
@@ -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 {
+1 -1
View File
@@ -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"`
}
+4 -4
View File
@@ -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 {
+5 -5
View File
@@ -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 {
+2 -2
View File
@@ -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 {
+6 -5
View File
@@ -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",
@@ -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)
},
}
+3 -3
View File
@@ -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 {
+2 -2
View File
@@ -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 {
+3 -3
View File
@@ -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 {
+3 -3
View File
@@ -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 {
+3 -3
View File
@@ -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 {
+11 -7
View File
@@ -8,8 +8,8 @@ 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 {
@@ -17,11 +17,6 @@ func CmdListRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry
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{
@@ -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)
},
}
+5 -7
View File
@@ -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",
+7 -5
View File
@@ -14,10 +14,10 @@ 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 {
@@ -25,7 +25,6 @@ func CmdRequestRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEn
GlobalOptions: GlobalOptions{
Template: figtree.NewStringOption("request"),
},
Method: "GET",
}
return &CommandRegistryEntry{
@@ -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)
},
}
+9 -7
View File
@@ -12,12 +12,12 @@ 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 {
@@ -25,7 +25,6 @@ func CmdSubtaskRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEn
GlobalOptions: GlobalOptions{
Template: figtree.NewStringOption("subtask"),
},
IssueType: "Sub-task",
Overrides: map[string]string{},
}
@@ -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)
},
}
+9 -7
View File
@@ -13,11 +13,11 @@ import (
)
type TransitionOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Overrides map[string]string
Transition string
Issue string
Resolution string
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 {
@@ -25,8 +25,7 @@ func CmdTransitionRegistry(fig *figtree.FigTree, o *oreo.Client, transition stri
GlobalOptions: GlobalOptions{
Template: figtree.NewStringOption("transition"),
},
Transition: transition,
Overrides: map[string]string{},
Overrides: map[string]string{},
}
help := "Transition issue to given state"
@@ -41,6 +40,9 @@ func CmdTransitionRegistry(fig *figtree.FigTree, o *oreo.Client, transition stri
},
func(cmd *kingpin.CmdClause) error {
LoadConfigs(cmd, fig, &opts)
if opts.Transition == "" {
opts.Transition = transition
}
return CmdTransitionUsage(cmd, &opts)
},
}
+2 -2
View File
@@ -8,8 +8,8 @@ import (
)
type TransitionsOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Issue string
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 {
+5 -3
View File
@@ -13,9 +13,7 @@ import (
)
func CmdUnexportTemplatesRegistry(fig *figtree.FigTree) *CommandRegistryEntry {
opts := ExportTemplatesOptions{
Dir: fmt.Sprintf("%s/.jira.d/templates", Homedir()),
}
opts := ExportTemplatesOptions{}
return &CommandRegistryEntry{
"Remove unmodified exported templates",
@@ -24,6 +22,10 @@ func CmdUnexportTemplatesRegistry(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)
},
}
+3 -3
View File
@@ -8,9 +8,9 @@ import (
)
type ViewOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
jira.IssueOptions `yaml:",inline" figtree:",inline"`
Issue string
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 {
+3 -3
View File
@@ -18,9 +18,9 @@ const (
)
type VoteOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Issue string
Action VoteAction
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 {
+4 -4
View File
@@ -18,10 +18,10 @@ const (
)
type WatchOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Issue string
Watcher string
Action WatchAction
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 {
+3 -3
View File
@@ -9,9 +9,9 @@ import (
)
type WorklogAddOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
jiradata.Worklog `yaml:",inline" figtree:",inline"`
Issue string
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 {
+2 -2
View File
@@ -8,8 +8,8 @@ import (
)
type WorklogListOptions struct {
GlobalOptions `yaml:",inline" figtree:",inline"`
Issue string
GlobalOptions `yaml:",inline" json:",inline" figtree:",inline"`
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdWorklogListRegistry(fig *figtree.FigTree, o *oreo.Client) *CommandRegistryEntry {