mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-18 20:23:28 +02:00
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
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() *jiracli.CommandRegistryEntry {
|
|
opts := jiracli.CommonOptions{
|
|
Template: figtree.NewStringOption("fields"),
|
|
}
|
|
return &jiracli.CommandRegistryEntry{
|
|
"Prints all fields, both System and Custom",
|
|
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
|
jiracli.LoadConfigs(cmd, fig, &opts)
|
|
jiracli.TemplateUsage(cmd, &opts)
|
|
return nil
|
|
},
|
|
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
|
|
return CmdFields(o, globals, &opts)
|
|
},
|
|
}
|
|
}
|
|
|
|
// Fields will send data from /rest/api/2/field API to "fields" template
|
|
func CmdFields(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.CommonOptions) error {
|
|
data, err := jira.GetFields(o, globals.Endpoint.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return jiracli.RunTemplate(opts.Template.Value, data, nil)
|
|
}
|