mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
test cobra
This commit is contained in:
parent
757fd4bf0b
commit
373b317b1a
@ -17,9 +17,9 @@ var startCmd = &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Start the server",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
port, _ := cmd.Flags().GetInt("port")
|
||||
configFolderPath, _ := cmd.Flags().GetString("config_folder_path")
|
||||
fmt.Printf("Starting server on port %s with config file at %s\n", port, configFolderPath)
|
||||
port, _ := cmd.Flags().GetInt(constant.FlagPort)
|
||||
configFolderPath, _ := cmd.Flags().GetString(constant.FlagConf)
|
||||
fmt.Printf("Starting server on port %d with config file at %s\n", port, configFolderPath)
|
||||
if err := run(configFolderPath, port); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
@ -27,8 +27,8 @@ var startCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func init() {
|
||||
startCmd.Flags().IntP("port", "p", 10002, "Port to listen on")
|
||||
startCmd.Flags().StringP("config_path", "c", "", "Path to config file folder")
|
||||
startCmd.Flags().IntP(constant.FlagPort, "p", 10002, "Port to listen on")
|
||||
startCmd.Flags().StringP(constant.FlagConf, "c", "", "Path to config file folder")
|
||||
}
|
||||
|
||||
func run(configFolderPath string, port int) error {
|
||||
|
@ -327,3 +327,9 @@ const LogFileName = "OpenIM.log"
|
||||
const CurrentVersion = "v2.3.4-rc0"
|
||||
|
||||
const LocalHost = "0.0.0.0"
|
||||
|
||||
// flag parse
|
||||
const (
|
||||
FlagPort = "port"
|
||||
FlagConf = "config_folder_path"
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user