Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cli
import (
"context"
"fmt"
"regexp"
"slices"
"strings"
"time"
Expand All @@ -17,11 +16,7 @@ const (
disableSliceFlagSeparator = false
)

var (
slPfx = fmt.Sprintf("sl:::%d:::", time.Now().UTC().UnixNano())

commaWhitespace = regexp.MustCompile("[, ]+.*")
)
var slPfx = fmt.Sprintf("sl:::%d:::", time.Now().UTC().UnixNano())

// GenerateShellCompletionFlag enables shell completion
var GenerateShellCompletionFlag Flag = &BoolFlag{
Expand Down Expand Up @@ -202,7 +197,11 @@ func FlagNames(name string, aliases []string) []string {
// Strip off anything after the first found comma or space, which
// *hopefully* makes it a tiny bit more obvious that unexpected behavior is
// caused by using the v1 form of stringly typed "Name".
ret = append(ret, commaWhitespace.ReplaceAllString(part, ""))
if i := strings.IndexAny(part, ", "); i >= 0 {
ret = append(ret, part[:i])
} else {
ret = append(ret, part)
}
}

return ret
Expand Down