You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/pkg/common/cmd/root.go

32 lines
706 B

package cmd
import (
"OpenIM/pkg/common/config"
"OpenIM/pkg/common/constant"
"github.com/spf13/cobra"
)
type RootCmd cobra.Command
func NewRootCmd() RootCmd {
c := cobra.Command{
Use: "start",
Short: "Start the server",
Long: `Start the server`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return getConfFromCmdAndInit(cmd)
},
}
c.Flags()
return RootCmd(c)
}
func (r RootCmd) Init() {
cobra.Command(r).Flags().StringP(constant.FlagConf, "c", "", "Path to config file folder")
}
func getConfFromCmdAndInit(cmdLines *cobra.Command) error {
configFolderPath, _ := cmdLines.Flags().GetString(constant.FlagConf)
return config.InitConfig(configFolderPath)
}