File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package cli
33import (
44 "context"
55 "fmt"
6- "regexp"
76 "slices"
87 "strings"
98 "time"
@@ -17,11 +16,7 @@ const (
1716 disableSliceFlagSeparator = false
1817)
1918
20- var (
21- slPfx = fmt .Sprintf ("sl:::%d:::" , time .Now ().UTC ().UnixNano ())
22-
23- commaWhitespace = regexp .MustCompile ("[, ]+.*" )
24- )
19+ var slPfx = fmt .Sprintf ("sl:::%d:::" , time .Now ().UTC ().UnixNano ())
2520
2621// GenerateShellCompletionFlag enables shell completion
2722var GenerateShellCompletionFlag Flag = & BoolFlag {
@@ -202,7 +197,11 @@ func FlagNames(name string, aliases []string) []string {
202197 // Strip off anything after the first found comma or space, which
203198 // *hopefully* makes it a tiny bit more obvious that unexpected behavior is
204199 // caused by using the v1 form of stringly typed "Name".
205- ret = append (ret , commaWhitespace .ReplaceAllString (part , "" ))
200+ if i := strings .IndexAny (part , ", " ); i >= 0 {
201+ ret = append (ret , part [:i ])
202+ } else {
203+ ret = append (ret , part )
204+ }
206205 }
207206
208207 return ret
You can’t perform that action at this time.
0 commit comments