mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 11:06:43 +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",
|
Short: "Start the server",
|
||||||
Long: `Start the server`,
|
Long: `Start the server`,
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if rootCmd.portFlag {
|
//if rootCmd.portFlag {
|
||||||
rootCmd.port = rootCmd.getPortFlag(cmd)
|
rootCmd.port = rootCmd.getPortFlag(cmd)
|
||||||
}
|
//}
|
||||||
if rootCmd.prometheusPortFlag {
|
//if rootCmd.prometheusPortFlag {
|
||||||
rootCmd.prometheusPort = rootCmd.getPrometheusPortFlag(cmd)
|
rootCmd.prometheusPort = rootCmd.getPrometheusPortFlag(cmd)
|
||||||
}
|
//}
|
||||||
return rootCmd.getConfFromCmdAndInit(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() {
|
func (r *RootCmd) init() {
|
||||||
r.Command.Flags().StringP(constant.FlagConf, "c", "", "Path to config file folder")
|
r.Command.Flags().StringP(constant.FlagConf, "c", "", "Path to config file folder")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user