diff --git a/go.mod b/go.mod index 53ae0ccd3..e0c620ace 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/regclient/regclient v0.11.2 github.com/sirupsen/logrus v1.9.4 github.com/stretchr/testify v1.11.1 - github.com/urfave/cli/v3 v3.7.0 + github.com/urfave/cli/v3 v3.8.0 go.uber.org/zap v1.27.1 golang.org/x/mod v0.34.0 k8s.io/api v0.35.3 diff --git a/go.sum b/go.sum index 1fb2890b5..2b2b89dae 100644 --- a/go.sum +++ b/go.sum @@ -230,8 +230,8 @@ github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY= github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= -github.com/urfave/cli/v3 v3.7.0 h1:AGSnbUyjtLiM+WJUb4dzXKldl/gL+F8OwmRDtVr6g2U= -github.com/urfave/cli/v3 v3.7.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso= +github.com/urfave/cli/v3 v3.8.0 h1:XqKPrm0q4P0q5JpoclYoCAv0/MIvH/jZ2umzuf8pNTI= +github.com/urfave/cli/v3 v3.8.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ= diff --git a/vendor/github.com/urfave/cli/v3/command.go b/vendor/github.com/urfave/cli/v3/command.go index 8f73fd28d..2a46b2eab 100644 --- a/vendor/github.com/urfave/cli/v3/command.go +++ b/vendor/github.com/urfave/cli/v3/command.go @@ -90,7 +90,7 @@ type Command struct { // default behavior. ExitErrHandler ExitErrHandlerFunc `json:"-"` // Other custom info - Metadata map[string]interface{} `json:"metadata"` + Metadata map[string]any `json:"metadata"` // Carries a function which returns app specific info. ExtraInfo func() map[string]string `json:"-"` // CustomRootCommandHelpTemplate the text template for app help topic. @@ -559,7 +559,7 @@ func (cmd *Command) Count(name string) int { } // Value returns the value of the flag corresponding to `name` -func (cmd *Command) Value(name string) interface{} { +func (cmd *Command) Value(name string) any { if fs := cmd.lookupFlag(name); fs != nil { tracef("value found for name %[1]q (cmd=%[2]q)", name, cmd.Name) return fs.Get() @@ -582,19 +582,14 @@ func (cmd *Command) NArg() int { func (cmd *Command) runFlagActions(ctx context.Context) error { tracef("runFlagActions") - for fl := range cmd.setFlags { - /*tracef("checking %v:%v", fl.Names(), fl.IsSet()) - if !fl.IsSet() { - continue - }*/ - - //if pf, ok := fl.(LocalFlag); ok && !pf.IsLocal() { - // continue - //} - - if af, ok := fl.(ActionableFlag); ok { - if err := af.RunAction(ctx, cmd); err != nil { - return err + // run the flag actions in the same order that they are defined + // to maintain consistency. + for _, fl := range cmd.appliedFlags { + if _, inSet := cmd.setFlags[fl]; inSet { + if af, ok := fl.(ActionableFlag); ok { + if err := af.RunAction(ctx, cmd); err != nil { + return err + } } } } diff --git a/vendor/github.com/urfave/cli/v3/command_parse.go b/vendor/github.com/urfave/cli/v3/command_parse.go index f8103d12f..92c58eeaa 100644 --- a/vendor/github.com/urfave/cli/v3/command_parse.go +++ b/vendor/github.com/urfave/cli/v3/command_parse.go @@ -80,7 +80,8 @@ func (cmd *Command) parseFlags(args Args) (Args, error) { firstArg := strings.TrimSpace(rargs[0]) if len(firstArg) == 0 { - break + posArgs = append(posArgs, rargs[0]) + continue } // stop parsing once we see a "--" @@ -163,8 +164,8 @@ func (cmd *Command) parseFlags(args Args) (Args, error) { tracef("processing non bool flag (fName=%[1]q)", flagName) // not a bool flag so need to get the next arg - if flagVal == "" { - if len(rargs) == 1 || valFromEqual { + if flagVal == "" && !valFromEqual { + if len(rargs) == 1 { return &stringSliceArgs{posArgs}, fmt.Errorf("%s%s", argumentNotProvidedErrMsg, firstArg) } flagVal = rargs[1] diff --git a/vendor/github.com/urfave/cli/v3/command_run.go b/vendor/github.com/urfave/cli/v3/command_run.go index e5cfff8a5..676a14c67 100644 --- a/vendor/github.com/urfave/cli/v3/command_run.go +++ b/vendor/github.com/urfave/cli/v3/command_run.go @@ -237,14 +237,18 @@ func (cmd *Command) run(ctx context.Context, osArgs []string) (_ context.Context }() } - for _, grp := range cmd.MutuallyExclusiveFlags { - if err := grp.check(cmd); err != nil { - if cmd.OnUsageError != nil { - err = cmd.OnUsageError(ctx, cmd, err, cmd.parent != nil) - } else { - _ = ShowSubcommandHelp(cmd) + // Walk the parent chain to check mutually exclusive flag groups + // defined on ancestor commands, since persistent flags are inherited. + for pCmd := cmd; pCmd != nil; pCmd = pCmd.parent { + for _, grp := range pCmd.MutuallyExclusiveFlags { + if err := grp.check(cmd); err != nil { + if cmd.OnUsageError != nil { + err = cmd.OnUsageError(ctx, cmd, err, cmd.parent != nil) + } else { + _ = ShowSubcommandHelp(cmd) + } + return ctx, err } - return ctx, err } } diff --git a/vendor/github.com/urfave/cli/v3/docs.go b/vendor/github.com/urfave/cli/v3/docs.go index 8ecdfc835..88461386b 100644 --- a/vendor/github.com/urfave/cli/v3/docs.go +++ b/vendor/github.com/urfave/cli/v3/docs.go @@ -35,21 +35,21 @@ func unquoteUsage(usage string) (string, string) { } func prefixedNames(names []string, placeholder string) string { - var prefixed string + var prefixed strings.Builder for i, name := range names { if name == "" { continue } - prefixed += prefixFor(name) + name + prefixed.WriteString(prefixFor(name) + name) if placeholder != "" { - prefixed += " " + placeholder + prefixed.WriteString(" " + placeholder) } if i < len(names)-1 { - prefixed += ", " + prefixed.WriteString(", ") } } - return prefixed + return prefixed.String() } func envFormat(envVars []string, prefix, sep, suffix string) string { diff --git a/vendor/github.com/urfave/cli/v3/flag.go b/vendor/github.com/urfave/cli/v3/flag.go index bfac8faaf..1b849f122 100644 --- a/vendor/github.com/urfave/cli/v3/flag.go +++ b/vendor/github.com/urfave/cli/v3/flag.go @@ -3,7 +3,7 @@ package cli import ( "context" "fmt" - "regexp" + "slices" "strings" "time" ) @@ -16,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{ @@ -201,20 +197,18 @@ 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 } func hasFlag(flags []Flag, fl Flag) bool { - for _, existing := range flags { - if fl == existing { - return true - } - } - - return false + return slices.Contains(flags, fl) } func flagSplitMultiValues(val string, sliceSeparator string, disableSliceSeparator bool) []string { diff --git a/vendor/github.com/urfave/cli/v3/flag_bool.go b/vendor/github.com/urfave/cli/v3/flag_bool.go index 0f2af27bf..f0ec22faf 100644 --- a/vendor/github.com/urfave/cli/v3/flag_bool.go +++ b/vendor/github.com/urfave/cli/v3/flag_bool.go @@ -69,7 +69,7 @@ func (b *boolValue) Set(s string) error { return err } -func (b *boolValue) Get() interface{} { return *b.destination } +func (b *boolValue) Get() any { return *b.destination } func (b *boolValue) String() string { return strconv.FormatBool(*b.destination) diff --git a/vendor/github.com/urfave/cli/v3/flag_impl.go b/vendor/github.com/urfave/cli/v3/flag_impl.go index c7cc8dffc..1ca295aaf 100644 --- a/vendor/github.com/urfave/cli/v3/flag_impl.go +++ b/vendor/github.com/urfave/cli/v3/flag_impl.go @@ -185,7 +185,7 @@ func (f *FlagBase[T, C, V]) Set(_ string, val string) error { // lots of units tests prior to persistent flags assumed that the // flag can be applied to different flag sets multiple times while still // keeping the env set. - if !f.applied || f.Local { + if !f.applied { if err := f.PreParse(); err != nil { return err } diff --git a/vendor/github.com/urfave/cli/v3/flag_map_impl.go b/vendor/github.com/urfave/cli/v3/flag_map_impl.go index b56d0a973..cb65903b9 100644 --- a/vendor/github.com/urfave/cli/v3/flag_map_impl.go +++ b/vendor/github.com/urfave/cli/v3/flag_map_impl.go @@ -115,7 +115,7 @@ func (i *MapBase[T, C, VC]) Value() map[string]T { } // Get returns the mapping of values set by this flag -func (i *MapBase[T, C, VC]) Get() interface{} { +func (i *MapBase[T, C, VC]) Get() any { return *i.dict } diff --git a/vendor/github.com/urfave/cli/v3/flag_slice_base.go b/vendor/github.com/urfave/cli/v3/flag_slice_base.go index 0248d8f1d..1f9561ae2 100644 --- a/vendor/github.com/urfave/cli/v3/flag_slice_base.go +++ b/vendor/github.com/urfave/cli/v3/flag_slice_base.go @@ -105,7 +105,7 @@ func (i *SliceBase[T, C, VC]) Value() []T { } // Get returns the slice of values set by this flag -func (i *SliceBase[T, C, VC]) Get() interface{} { +func (i *SliceBase[T, C, VC]) Get() any { return *i.slice } diff --git a/vendor/github.com/urfave/cli/v3/godoc-current.txt b/vendor/github.com/urfave/cli/v3/godoc-current.txt index 9784c4e2b..a31fb2108 100644 --- a/vendor/github.com/urfave/cli/v3/godoc-current.txt +++ b/vendor/github.com/urfave/cli/v3/godoc-current.txt @@ -499,7 +499,7 @@ type Command struct { // default behavior. ExitErrHandler ExitErrHandlerFunc `json:"-"` // Other custom info - Metadata map[string]interface{} `json:"metadata"` + Metadata map[string]any `json:"metadata"` // Carries a function which returns app specific info. ExtraInfo func() map[string]string `json:"-"` // CustomRootCommandHelpTemplate the text template for app help topic. @@ -777,7 +777,7 @@ func (cmd *Command) UintSlice(name string) []uint UintSlice looks up the value of a local UintSliceFlag, returns nil if not found -func (cmd *Command) Value(name string) interface{} +func (cmd *Command) Value(name string) any Value returns the value of the flag corresponding to `name` func (cmd *Command) VisibleCategories() []CommandCategory @@ -1225,7 +1225,7 @@ func NewMapBase[T any, C any, VC ValueCreator[T, C]](defaults map[string]T) *Map func (i MapBase[T, C, VC]) Create(val map[string]T, p *map[string]T, c C) Value -func (i *MapBase[T, C, VC]) Get() interface{} +func (i *MapBase[T, C, VC]) Get() any Get returns the mapping of values set by this flag func (i *MapBase[T, C, VC]) Serialize() string @@ -1312,7 +1312,7 @@ func NewSliceBase[T any, C any, VC ValueCreator[T, C]](defaults ...T) *SliceBase func (i SliceBase[T, C, VC]) Create(val []T, p *[]T, c C) Value -func (i *SliceBase[T, C, VC]) Get() interface{} +func (i *SliceBase[T, C, VC]) Get() any Get returns the slice of values set by this flag func (i *SliceBase[T, C, VC]) Serialize() string diff --git a/vendor/github.com/urfave/cli/v3/help.go b/vendor/github.com/urfave/cli/v3/help.go index 9db9df510..0f7f629ca 100644 --- a/vendor/github.com/urfave/cli/v3/help.go +++ b/vendor/github.com/urfave/cli/v3/help.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "slices" "strings" "text/tabwriter" "text/template" @@ -204,10 +205,8 @@ func cliArgContains(flagName string, args []string) bool { count = 2 } flag := fmt.Sprintf("%s%s", strings.Repeat("-", count), name) - for _, a := range args { - if a == flag { - return true - } + if slices.Contains(args, flag) { + return true } } return false @@ -496,13 +495,11 @@ func checkShellCompleteFlag(c *Command, arguments []string) (bool, []string) { return false, arguments } - for _, arg := range arguments { - // If arguments include "--", shell completion is disabled - // because after "--" only positional arguments are accepted. - // https://unix.stackexchange.com/a/11382 - if arg == "--" { - return false, arguments[:pos] - } + // If arguments include "--", shell completion is disabled + // because after "--" only positional arguments are accepted. + // https://unix.stackexchange.com/a/11382 + if slices.Contains(arguments, "--") { + return false, arguments[:pos] } return true, arguments[:pos] diff --git a/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt b/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt index e41a984db..e5848c726 100644 --- a/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt +++ b/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt @@ -1,5 +1,5 @@ mkdocs-git-revision-date-localized-plugin==1.5.1 -mkdocs-material==9.7.1 +mkdocs-material==9.7.5 mkdocs==1.6.1 mkdocs-redirects==1.2.2 pygments==2.19.2 diff --git a/vendor/github.com/urfave/cli/v3/suggestions.go b/vendor/github.com/urfave/cli/v3/suggestions.go index 6f29f1221..401dcef25 100644 --- a/vendor/github.com/urfave/cli/v3/suggestions.go +++ b/vendor/github.com/urfave/cli/v3/suggestions.go @@ -92,7 +92,7 @@ func jaroWinkler(a, b string) float64 { prefix := int(math.Min(float64(len(a)), math.Min(float64(prefixSize), float64(len(b))))) var prefixMatch float64 - for i := 0; i < prefix; i++ { + for i := range prefix { if a[i] == b[i] { prefixMatch++ } else { diff --git a/vendor/modules.txt b/vendor/modules.txt index b2aa32fb5..57dc0d17a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -397,7 +397,7 @@ github.com/ulikunitz/xz github.com/ulikunitz/xz/internal/hash github.com/ulikunitz/xz/internal/xlog github.com/ulikunitz/xz/lzma -# github.com/urfave/cli/v3 v3.7.0 +# github.com/urfave/cli/v3 v3.8.0 ## explicit; go 1.22 github.com/urfave/cli/v3 # github.com/x448/float16 v0.8.4