Skip to content

Commit

Permalink
config: Add config:explain, config:print commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
octavore committed Feb 5, 2024
1 parent 90e68de commit 04fc93c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions config/commands.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package config

import (
"fmt"

"github.com/octavore/naga/service"
)

func (m *Module) registerCommands(c *service.Config) {
c.AddCommand(&service.Command{
Keyword: "config:explain",
Run: func(ctx *service.CommandContext) {
m.PrintConsolidatedConfig()
},
ShortUsage: "Explain config.json options",
Usage: "",
})

c.AddCommand(&service.Command{
Keyword: "config:print",
Run: func(ctx *service.CommandContext) {
fmt.Println(string(m.Byte))
},
ShortUsage: "Print current config.json",
Usage: "",
})
}
2 changes: 2 additions & 0 deletions config/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type Module struct {

// Init implements the module interface method
func (m *Module) Init(c *service.Config) {
m.registerCommands(c)

c.Setup = func() error {
m.configDefs = []reflect.Type{}
switch {
Expand Down

0 comments on commit 04fc93c

Please sign in to comment.