From 96bff3c5e14817f280e251e7925d5322c9ae5dce Mon Sep 17 00:00:00 2001 From: Naveen Gogineni Date: Wed, 19 Oct 2022 09:44:21 -0400 Subject: [PATCH] Remove flag_windows and use runtime --- flag.go | 10 +++++++++- flag_windows.go | 14 -------------- 2 files changed, 9 insertions(+), 15 deletions(-) delete mode 100644 flag_windows.go diff --git a/flag.go b/flag.go index 63af8dd76d..7535424c04 100644 --- a/flag.go +++ b/flag.go @@ -5,7 +5,9 @@ import ( "flag" "fmt" "io/ioutil" + "os" "regexp" + "runtime" "strings" "syscall" "time" @@ -279,7 +281,13 @@ func defaultEnvFormat(envVars []string) string { } func withEnvHint(envVars []string, str string) string { - return str + defaultEnvFormat(envVars) + envText := "" + if runtime.GOOS != "windows" || os.Getenv("PSHOME") != "" { + envText = defaultEnvFormat(envVars) + } else { + envText = envFormat(envVars, "%", "%, %", "%") + } + return str + envText } func FlagNames(name string, aliases []string) []string { diff --git a/flag_windows.go b/flag_windows.go deleted file mode 100644 index 1586412cc7..0000000000 --- a/flag_windows.go +++ /dev/null @@ -1,14 +0,0 @@ -package cli - -import "os" - -func withEnvHint(envVars []string, str string) string { - // if we are running is powershell this env var is set - // and so we should use the default env format - if os.Getenv("PSHOME") != "" { - envText = defaultEnvFormat(envVars) - } else { - envText = envFormat(envVars, "%", "%, %", "%") - } - return str + envText -}