large refactor, fixes #2

This commit is contained in:
Craig
2020-01-18 23:30:09 +00:00
parent 2729c66ccc
commit 7aa034f3ba
59 changed files with 2766 additions and 1345 deletions

View File

@ -3,16 +3,16 @@ package main
import (
"fmt"
"github.com/rs/zerolog/log"
"n.eko.moe/neko"
"n.eko.moe/neko/cmd"
"n.eko.moe/neko/internal/utils"
"github.com/rs/zerolog/log"
)
func main() {
fmt.Print(utils.Colorf(utils.Header, "server", neko.Service.Version))
fmt.Print(utils.Colorf(neko.Header, "server", neko.Service.Version))
if err := cmd.Execute(); err != nil {
log.Panic().Err(err).Msg("Failed to execute command")
log.Panic().Err(err).Msg("failed to execute command")
}
}

View File

@ -3,10 +3,11 @@ package cmd
import (
"fmt"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"n.eko.moe/neko"
"n.eko.moe/neko/internal/preflight"
"github.com/spf13/cobra"
)
func Execute() error {
@ -15,8 +16,8 @@ func Execute() error {
var root = &cobra.Command{
Use: "neko",
Short: "",
Long: ``,
Short: "neko streaming server",
Long: `neko streaming server`,
Version: neko.Service.Version.String(),
}
@ -28,8 +29,8 @@ func init() {
})
if err := neko.Service.Root.Init(root); err != nil {
neko.Service.Logger.Panic().Err(err).Msg("Unable to run command")
log.Panic().Err(err).Msg("unable to run root command")
}
root.SetVersionTemplate(fmt.Sprintf("Version: %s\n", neko.Service.Version))
root.SetVersionTemplate(fmt.Sprintf("version: %s\n", neko.Service.Version))
}

View File

@ -11,13 +11,15 @@ import (
func init() {
command := &cobra.Command{
Use: "serve",
Short: "",
Long: ``,
Short: "serve neko streaming server",
Long: `serve neko streaming server`,
Run: neko.Service.ServeCommand,
}
configs := []config.Config{
neko.Service.Serve,
neko.Service.Server,
neko.Service.WebRTC,
neko.Service.WebSocket,
}
cobra.OnInitialize(func() {
@ -29,7 +31,7 @@ func init() {
for _, cfg := range configs {
if err := cfg.Init(command); err != nil {
log.Panic().Err(err).Msg("Unable to run command")
log.Panic().Err(err).Msg("unable to run serve command")
}
}