gosocketio/cli/root.go

44 lines
757 B
Go
Raw Permalink Normal View History

2023-11-25 22:27:57 +08:00
package cli
import (
"fmt"
"os"
2023-11-28 23:26:58 +08:00
"git.pyer.club/kingecg/gologger"
"git.pyer.club/kingecg/gosocketio/config"
2023-11-25 22:27:57 +08:00
"github.com/spf13/cobra"
)
2023-11-28 23:26:58 +08:00
var (
configFile string
rootCmd = &cobra.Command{
Use: "gosocketio",
Short: "A golang socket.io server",
Run: func(cmd *cobra.Command, args []string) {
},
}
)
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "", "config file")
}
func initConfig() {
if configFile != "" {
config.LoadConfig(configFile)
}
gologger.Configure(config.GetConfig().Logging)
logger := gologger.GetLogger("main")
logger.Debug("On init")
2023-11-25 22:27:57 +08:00
}
// run app cmd
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}