fix(version): command line flag
This commit is contained in:
@@ -79,7 +79,6 @@ type CronSchedule struct {
|
||||
func SetVersion(version string) {
|
||||
version = strings.TrimRight(version, versionTrimRightCutSet)
|
||||
viper.Set(WingmateVersion, version)
|
||||
wingmate.Log().Info().Msgf("starting wingmate version %s", version)
|
||||
}
|
||||
|
||||
func Read() (*Config, error) {
|
||||
@@ -91,8 +90,6 @@ func Read() (*Config, error) {
|
||||
viper.SetDefault(PidProxyPathConfig, PidProxyPathDefault)
|
||||
viper.SetDefault(ExecPathConfig, ExecPathDefault)
|
||||
|
||||
ParseFlags()
|
||||
|
||||
var (
|
||||
dirent []os.DirEntry
|
||||
err error
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func ParseFlags() {
|
||||
pflag.BoolP(VersionFlag, "v", false, "check version")
|
||||
pflag.CountP(VersionFlag, "v", "check version")
|
||||
pflag.String(WMPidProxyPathFlag, "", "wmpidproxy path")
|
||||
pflag.String(WMExecPathFlag, "", "wmexec path")
|
||||
pflag.StringP(ConfigPathFlag, "c", "", "config path")
|
||||
@@ -17,4 +20,9 @@ func ParseFlags() {
|
||||
_ = viper.BindPFlag(ConfigPath, pflag.CommandLine.Lookup(ConfigPathFlag))
|
||||
_ = viper.BindPFlag(PidProxyPathConfig, pflag.CommandLine.Lookup(WMPidProxyPathFlag))
|
||||
_ = viper.BindPFlag(ExecPathConfig, pflag.CommandLine.Lookup(WMExecPathFlag))
|
||||
|
||||
if viper.GetInt(VersionCheckKey) > 0 {
|
||||
fmt.Println(viper.GetString(WingmateVersion))
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user