mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-03 07:01:35 -06:00
39 lines
705 B
Go
39 lines
705 B
Go
package cmd
|
|
|
|
import (
|
|
"github.com/rs/zerolog/log"
|
|
"github.com/spf13/cobra"
|
|
|
|
"m1k1o/neko_rooms"
|
|
"m1k1o/neko_rooms/internal/config"
|
|
)
|
|
|
|
func init() {
|
|
command := &cobra.Command{
|
|
Use: "serve",
|
|
Short: "serve neko_rooms server",
|
|
Long: `serve neko_rooms server`,
|
|
Run: neko_rooms.Service.ServeCommand,
|
|
}
|
|
|
|
configs := []config.Config{
|
|
neko_rooms.Service.Configs.Server,
|
|
neko_rooms.Service.Configs.API,
|
|
}
|
|
|
|
cobra.OnInitialize(func() {
|
|
for _, cfg := range configs {
|
|
cfg.Set()
|
|
}
|
|
neko_rooms.Service.Preflight()
|
|
})
|
|
|
|
for _, cfg := range configs {
|
|
if err := cfg.Init(command); err != nil {
|
|
log.Panic().Err(err).Msg("unable to run serve command")
|
|
}
|
|
}
|
|
|
|
root.AddCommand(command)
|
|
}
|