package cli import ( "fmt" "os" "git.pyer.club/kingecg/gologger" "git.pyer.club/kingecg/gosocketio/config" "github.com/spf13/cobra" ) 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") } // run app cmd func Execute() { if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(1) } }