This commit is contained in:
wangchuxiao
2023-03-09 13:26:58 +08:00
parent 046d645ef6
commit 0c98231fcd
6 changed files with 42 additions and 43 deletions
+11 -1
View File
@@ -7,7 +7,9 @@ import (
)
type RootCmd struct {
Command cobra.Command
Command cobra.Command
port int
prometheusPort int
}
func NewRootCmd() (rootCmd *RootCmd) {
@@ -50,6 +52,10 @@ func (r *RootCmd) getPortFlag(cmd *cobra.Command) int {
return port
}
func (r *RootCmd) GetPortFlag() int {
return r.port
}
func (r *RootCmd) AddPrometheusPortFlag() {
r.Command.Flags().String(constant.FlagPrometheusPort, "", "server prometheus listen port")
}
@@ -59,6 +65,10 @@ func (r *RootCmd) getPrometheusPortFlag(cmd *cobra.Command) int {
return port
}
func (r *RootCmd) GetPrometheusPortFlag() int {
return r.prometheusPort
}
func (r *RootCmd) getConfFromCmdAndInit(cmdLines *cobra.Command) error {
configFolderPath, _ := cmdLines.Flags().GetString(constant.FlagConf)
return config.InitConfig(configFolderPath)