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
30e9b44054
commit
60876e865b
@ -22,12 +22,12 @@ func NewRootCmd() (rootCmd *RootCmd) {
|
||||
Short: "Start the server",
|
||||
Long: `Start the server`,
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
if rootCmd.portFlag {
|
||||
rootCmd.port = rootCmd.getPortFlag(cmd)
|
||||
}
|
||||
if rootCmd.prometheusPortFlag {
|
||||
rootCmd.prometheusPort = rootCmd.getPrometheusPortFlag(cmd)
|
||||
}
|
||||
//if rootCmd.portFlag {
|
||||
rootCmd.port = rootCmd.getPortFlag(cmd)
|
||||
//}
|
||||
//if rootCmd.prometheusPortFlag {
|
||||
rootCmd.prometheusPort = rootCmd.getPrometheusPortFlag(cmd)
|
||||
//}
|
||||
return rootCmd.getConfFromCmdAndInit(cmd)
|
||||
},
|
||||
}
|
||||
@ -42,6 +42,12 @@ func (r *RootCmd) AddRunE(f func(cmd RootCmd) error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RootCmd) AddRpc(f func(port, prometheusPort int) error) {
|
||||
r.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||
return f(r.port, r.prometheusPort)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RootCmd) init() {
|
||||
r.Command.Flags().StringP(constant.FlagConf, "c", "", "Path to config file folder")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user