integrate kingpeon library to allow for custom commands via configuration

This commit is contained in:
Cory Bennett
2017-08-31 15:08:24 -07:00
parent b4d7845105
commit 301a61f2f1
11 changed files with 1260 additions and 1 deletions
+17
View File
@@ -8,6 +8,7 @@ import (
"runtime/debug"
"github.com/coryb/figtree"
"github.com/coryb/kingpeon"
"github.com/coryb/oreo"
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
@@ -280,6 +281,22 @@ func main() {
jiracli.Register(app, registry)
// register custom commands
data := struct {
CustomCommands kingpeon.DynamicCommands `yaml:"custom-commands" json":custom-commands"`
}{}
if err := fig.LoadAllConfigs("config.yml", &data); err != nil {
log.Errorf("%s", err)
panic(jiracli.Exit{Code: 1})
}
if len(data.CustomCommands) > 0 {
tmp := map[string]interface{}{}
fig.LoadAllConfigs("config.yml", &tmp)
kingpeon.RegisterDynamicCommands(app, data.CustomCommands, jiracli.TemplateProcessor())
}
app.Terminate(func(status int) {
for _, arg := range os.Args {
if arg == "-h" || arg == "--help" || len(os.Args) == 1 {