mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
configs to root.
This commit is contained in:
22
cmd/root.go
22
cmd/root.go
@ -16,6 +16,8 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"demodesk/neko"
|
||||
"demodesk/neko/internal/config"
|
||||
"demodesk/neko/modules"
|
||||
)
|
||||
|
||||
func Execute() error {
|
||||
@ -30,6 +32,16 @@ var root = &cobra.Command{
|
||||
}
|
||||
|
||||
func init() {
|
||||
configs := append([]config.Config{
|
||||
neko.Service.Configs.Root,
|
||||
neko.Service.Configs.Desktop,
|
||||
neko.Service.Configs.Capture,
|
||||
neko.Service.Configs.WebRTC,
|
||||
neko.Service.Configs.Member,
|
||||
neko.Service.Configs.Session,
|
||||
neko.Service.Configs.Server,
|
||||
}, modules.Configs()...)
|
||||
|
||||
cobra.OnInitialize(func() {
|
||||
//////
|
||||
// logs
|
||||
@ -126,11 +138,15 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
neko.Service.Configs.Root.Set()
|
||||
for _, cfg := range configs {
|
||||
cfg.Set()
|
||||
}
|
||||
})
|
||||
|
||||
if err := neko.Service.Configs.Root.Init(root); err != nil {
|
||||
log.Panic().Err(err).Msg("unable to run root command")
|
||||
for _, cfg := range configs {
|
||||
if err := cfg.Init(root); err != nil {
|
||||
log.Panic().Err(err).Msg("unable to initialize configuration")
|
||||
}
|
||||
}
|
||||
|
||||
root.SetVersionTemplate(neko.Service.Version.Details())
|
||||
|
@ -33,14 +33,7 @@ func init() {
|
||||
Run: service.ServeCommand,
|
||||
}
|
||||
|
||||
cobra.OnInitialize(func() {
|
||||
service.Configs.Set()
|
||||
service.Preflight()
|
||||
})
|
||||
|
||||
if err := service.Configs.Init(command); err != nil {
|
||||
log.Panic().Err(err).Msg("unable to run serve command")
|
||||
}
|
||||
cobra.OnInitialize(service.Preflight)
|
||||
|
||||
root.AddCommand(command)
|
||||
}
|
||||
|
Reference in New Issue
Block a user