From f69b6df766271df3aab74a7251a48da7238872cf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Nov 2025 07:05:25 +0000 Subject: [PATCH] Bump github.com/urfave/cli/v3 from 3.5.0 to 3.6.0 Bumps [github.com/urfave/cli/v3](https://github.com/urfave/cli) from 3.5.0 to 3.6.0. - [Release notes](https://github.com/urfave/cli/releases) - [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md) - [Commits](https://github.com/urfave/cli/compare/v3.5.0...v3.6.0) --- updated-dependencies: - dependency-name: github.com/urfave/cli/v3 dependency-version: 3.6.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/urfave/cli/v3/command.go | 34 +++++++++++++++ .../github.com/urfave/cli/v3/command_parse.go | 2 +- .../github.com/urfave/cli/v3/command_run.go | 5 +++ .../github.com/urfave/cli/v3/command_setup.go | 43 +++++++++++-------- vendor/github.com/urfave/cli/v3/flag.go | 11 +++-- vendor/github.com/urfave/cli/v3/flag_impl.go | 22 ++++++++++ .../github.com/urfave/cli/v3/flag_map_impl.go | 38 +++++++++++++--- .../urfave/cli/v3/flag_slice_base.go | 18 ++++++-- .../urfave/cli/v3/godoc-current.txt | 2 + .../urfave/cli/v3/mkdocs-requirements.txt | 4 +- vendor/modules.txt | 2 +- 13 files changed, 149 insertions(+), 38 deletions(-) diff --git a/go.mod b/go.mod index e0763580b..e66905b31 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/regclient/regclient v0.9.2 github.com/sirupsen/logrus v1.9.3 github.com/stretchr/testify v1.11.1 - github.com/urfave/cli/v3 v3.5.0 + github.com/urfave/cli/v3 v3.6.0 go.uber.org/automaxprocs v1.6.0 go.uber.org/zap v1.27.0 golang.org/x/mod v0.29.0 diff --git a/go.sum b/go.sum index 655ce482f..c9985add2 100644 --- a/go.sum +++ b/go.sum @@ -215,8 +215,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.5.0 h1:qCuFMmdayTF3zmjG8TSsoBzrDqszNrklYg2x3g4MSgw= -github.com/urfave/cli/v3 v3.5.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso= +github.com/urfave/cli/v3 v3.6.0 h1:oIdArVjkdIXHWg3iqxgmqwQGC8NM0JtdgwQAj2sRwFo= +github.com/urfave/cli/v3 v3.6.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 3eebbaff7..2572c3637 100644 --- a/vendor/github.com/urfave/cli/v3/command.go +++ b/vendor/github.com/urfave/cli/v3/command.go @@ -101,6 +101,8 @@ type Command struct { SliceFlagSeparator string `json:"sliceFlagSeparator"` // DisableSliceFlagSeparator is used to disable SliceFlagSeparator, the default is false DisableSliceFlagSeparator bool `json:"disableSliceFlagSeparator"` + // MapFlagKeyValueSeparator is used to customize the separator for MapFlag, the default is "=" + MapFlagKeyValueSeparator string `json:"mapFlagKeyValueSeparator"` // Boolean to enable short-option handling so user can combine several // single-character bool arguments into one // i.e. foobar -o -v -> foobar -ov @@ -155,6 +157,10 @@ type Command struct { didSetupDefaults bool // whether in shell completion mode shellCompletion bool + // whether global help flag was added + globaHelpFlagAdded bool + // whether global version flag was added + globaVersionFlagAdded bool } // FullName returns the full name of the command. @@ -349,6 +355,7 @@ func (cmd *Command) Root() *Command { func (cmd *Command) set(fName string, f Flag, val string) error { cmd.setFlags[f] = struct{}{} + cmd.setMultiValueParsingConfig(f) if err := f.Set(fName, val); err != nil { return fmt.Errorf("invalid value %q for flag -%s: %v", val, fName, err) } @@ -377,6 +384,21 @@ func (cmd *Command) lookupFlag(name string) Flag { return nil } +// this looks up only allowed flags, i.e. local flags for current command +// or persistent flags from ancestors +func (cmd *Command) lookupAppliedFlag(name string) Flag { + for _, f := range cmd.appliedFlags { + if slices.Contains(f.Names(), name) { + tracef("appliedFlag found for name %[1]q (cmd=%[2]q)", name, cmd.Name) + return f + } + } + + tracef("lookupAppliedflag NOT found for name %[1]q (cmd=%[2]q)", name, cmd.Name) + cmd.onInvalidFlag(context.TODO(), name) + return nil +} + func (cmd *Command) checkRequiredFlag(f Flag) (bool, string) { if rf, ok := f.(RequiredFlag); ok && rf.IsRequired() { flagName := f.Names()[0] @@ -440,9 +462,21 @@ func (cmd *Command) NumFlags() int { return count // cmd.flagSet.NFlag() } +func (cmd *Command) setMultiValueParsingConfig(f Flag) { + tracef("setMultiValueParsingConfig %T, %+v", f, f) + if cf, ok := f.(multiValueParsingConfigSetter); ok { + cf.setMultiValueParsingConfig(multiValueParsingConfig{ + SliceFlagSeparator: cmd.SliceFlagSeparator, + DisableSliceFlagSeparator: cmd.DisableSliceFlagSeparator, + MapFlagKeyValueSeparator: cmd.MapFlagKeyValueSeparator, + }) + } +} + // Set sets a context flag to a value. func (cmd *Command) Set(name, value string) error { if f := cmd.lookupFlag(name); f != nil { + cmd.setMultiValueParsingConfig(f) return f.Set(name, value) } diff --git a/vendor/github.com/urfave/cli/v3/command_parse.go b/vendor/github.com/urfave/cli/v3/command_parse.go index 7e3e0ab35..e57e16442 100644 --- a/vendor/github.com/urfave/cli/v3/command_parse.go +++ b/vendor/github.com/urfave/cli/v3/command_parse.go @@ -144,7 +144,7 @@ func (cmd *Command) parseFlags(args Args) (Args, error) { tracef("flagName:2 (fName=%[1]q) (fVal=%[2]q)", flagName, flagVal) - f := cmd.lookupFlag(flagName) + f := cmd.lookupAppliedFlag(flagName) // found a flag matching given flagName if f != nil { tracef("Trying flag type (fName=%[1]q) (type=%[2]T)", flagName, f) diff --git a/vendor/github.com/urfave/cli/v3/command_run.go b/vendor/github.com/urfave/cli/v3/command_run.go index 855eb9732..578683da4 100644 --- a/vendor/github.com/urfave/cli/v3/command_run.go +++ b/vendor/github.com/urfave/cli/v3/command_run.go @@ -207,9 +207,14 @@ func (cmd *Command) run(ctx context.Context, osArgs []string) (_ context.Context } for _, flag := range cmd.allFlags() { + isSet := flag.IsSet() if err := flag.PostParse(); err != nil { return ctx, err } + // add env set flags here + if !isSet && flag.IsSet() { + cmd.setFlags[flag] = struct{}{} + } } if cmd.After != nil && !cmd.Root().shellCompletion { diff --git a/vendor/github.com/urfave/cli/v3/command_setup.go b/vendor/github.com/urfave/cli/v3/command_setup.go index 09df4a308..cac4a3031 100644 --- a/vendor/github.com/urfave/cli/v3/command_setup.go +++ b/vendor/github.com/urfave/cli/v3/command_setup.go @@ -80,7 +80,18 @@ func (cmd *Command) setupDefaults(osArgs []string) { if !cmd.HideVersion && isRoot { tracef("appending version flag (cmd=%[1]q)", cmd.Name) - cmd.appendFlag(VersionFlag) + if !cmd.globaVersionFlagAdded { + var localVersionFlag Flag + if globalVersionFlag, ok := VersionFlag.(*BoolFlag); ok { + flag := *globalVersionFlag + localVersionFlag = &flag + } else { + localVersionFlag = VersionFlag + } + + cmd.appendFlag(localVersionFlag) + cmd.globaVersionFlagAdded = true + } } if cmd.PrefixMatchCommands && cmd.SuggestCommandFunc == nil { @@ -130,14 +141,6 @@ func (cmd *Command) setupDefaults(osArgs []string) { cmd.Metadata = map[string]any{} } - if len(cmd.SliceFlagSeparator) != 0 { - tracef("setting defaultSliceFlagSeparator from cmd.SliceFlagSeparator (cmd=%[1]q)", cmd.Name) - defaultSliceFlagSeparator = cmd.SliceFlagSeparator - } - - tracef("setting disableSliceFlagSeparator from cmd.DisableSliceFlagSeparator (cmd=%[1]q)", cmd.Name) - disableSliceFlagSeparator = cmd.DisableSliceFlagSeparator - cmd.setFlags = map[Flag]struct{}{} } @@ -200,15 +203,21 @@ func (cmd *Command) ensureHelp() { } if HelpFlag != nil { - // TODO need to remove hack - if hf, ok := HelpFlag.(*BoolFlag); ok { - hf.applied = false - hf.hasBeenSet = false - hf.Value = false - hf.value = nil + if !cmd.globaHelpFlagAdded { + var localHelpFlag Flag + if globalHelpFlag, ok := HelpFlag.(*BoolFlag); ok { + flag := *globalHelpFlag + localHelpFlag = &flag + } else { + localHelpFlag = HelpFlag + } + + tracef("appending HelpFlag (cmd=%[1]q)", cmd.Name) + cmd.appendFlag(localHelpFlag) + cmd.globaHelpFlagAdded = true + } else { + tracef("HelpFlag already added, skip (cmd=%[1]q)", cmd.Name) } - tracef("appending HelpFlag (cmd=%[1]q)", cmd.Name) - cmd.appendFlag(HelpFlag) } } } diff --git a/vendor/github.com/urfave/cli/v3/flag.go b/vendor/github.com/urfave/cli/v3/flag.go index a5bd54748..6ff83f520 100644 --- a/vendor/github.com/urfave/cli/v3/flag.go +++ b/vendor/github.com/urfave/cli/v3/flag.go @@ -10,7 +10,7 @@ import ( const defaultPlaceholder = "value" -var ( +const ( defaultSliceFlagSeparator = "," defaultMapFlagKeyValueSeparator = "=" disableSliceFlagSeparator = false @@ -222,10 +222,13 @@ func hasFlag(flags []Flag, fl Flag) bool { return false } -func flagSplitMultiValues(val string) []string { - if disableSliceFlagSeparator { +func flagSplitMultiValues(val string, sliceSeparator string, disableSliceSeparator bool) []string { + if disableSliceSeparator { return []string{val} } - return strings.Split(val, defaultSliceFlagSeparator) + if len(sliceSeparator) == 0 { + sliceSeparator = defaultSliceFlagSeparator + } + return strings.Split(val, sliceSeparator) } diff --git a/vendor/github.com/urfave/cli/v3/flag_impl.go b/vendor/github.com/urfave/cli/v3/flag_impl.go index d4390ee2d..c7cc8dffc 100644 --- a/vendor/github.com/urfave/cli/v3/flag_impl.go +++ b/vendor/github.com/urfave/cli/v3/flag_impl.go @@ -19,6 +19,20 @@ type boolFlag interface { IsBoolFlag() bool } +type multiValueParsingConfig struct { + // SliceFlagSeparator is used to customize the separator for SliceFlag, the default is "," + SliceFlagSeparator string + // DisableSliceFlagSeparator is used to disable SliceFlagSeparator, the default is false + DisableSliceFlagSeparator bool + // MapFlagKeyValueSeparator is used to customize the separator for MapFlag, the default is "=" + MapFlagKeyValueSeparator string +} + +type multiValueParsingConfigSetter interface { + // configuration of parsing + setMultiValueParsingConfig(c multiValueParsingConfig) +} + // ValueCreator is responsible for creating a flag.Value emulation // as well as custom formatting // @@ -134,6 +148,14 @@ func (f *FlagBase[T, C, V]) PostParse() error { return nil } +// pass configuration of parsing to value +func (f *FlagBase[T, C, V]) setMultiValueParsingConfig(c multiValueParsingConfig) { + tracef("setMultiValueParsingConfig %T, %+v", f.value, f.value) + if cf, ok := f.value.(multiValueParsingConfigSetter); ok { + cf.setMultiValueParsingConfig(c) + } +} + func (f *FlagBase[T, C, V]) PreParse() error { newVal := f.Value 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 b03514b7d..b56d0a973 100644 --- a/vendor/github.com/urfave/cli/v3/flag_map_impl.go +++ b/vendor/github.com/urfave/cli/v3/flag_map_impl.go @@ -10,9 +10,10 @@ import ( // MapBase wraps map[string]T to satisfy flag.Value type MapBase[T any, C any, VC ValueCreator[T, C]] struct { - dict *map[string]T - hasBeenSet bool - value Value + dict *map[string]T + hasBeenSet bool + value Value + multiValueConfig multiValueParsingConfig } func (i MapBase[T, C, VC]) Create(val map[string]T, p *map[string]T, c C) Value { @@ -36,6 +37,18 @@ func NewMapBase[T any, C any, VC ValueCreator[T, C]](defaults map[string]T) *Map } } +// configuration of slicing +func (i *MapBase[T, C, VC]) setMultiValueParsingConfig(c multiValueParsingConfig) { + i.multiValueConfig = c + mvc := &i.multiValueConfig + tracef( + "set map parsing config - keyValueSeparator '%s', slice separator '%s', disable separator:%v", + mvc.MapFlagKeyValueSeparator, + mvc.SliceFlagSeparator, + mvc.DisableSliceFlagSeparator, + ) +} + // Set parses the value and appends it to the list of values func (i *MapBase[T, C, VC]) Set(value string) error { if !i.hasBeenSet { @@ -50,10 +63,23 @@ func (i *MapBase[T, C, VC]) Set(value string) error { return nil } - for _, item := range flagSplitMultiValues(value) { - key, value, ok := strings.Cut(item, defaultMapFlagKeyValueSeparator) + mvc := &i.multiValueConfig + keyValueSeparator := mvc.MapFlagKeyValueSeparator + if len(keyValueSeparator) == 0 { + keyValueSeparator = defaultMapFlagKeyValueSeparator + } + + tracef( + "splitting map value '%s', keyValueSeparator '%s', slice separator '%s', disable separator:%v", + value, + keyValueSeparator, + mvc.SliceFlagSeparator, + mvc.DisableSliceFlagSeparator, + ) + for _, item := range flagSplitMultiValues(value, mvc.SliceFlagSeparator, mvc.DisableSliceFlagSeparator) { + key, value, ok := strings.Cut(item, keyValueSeparator) if !ok { - return fmt.Errorf("item %q is missing separator %q", item, defaultMapFlagKeyValueSeparator) + return fmt.Errorf("item %q is missing separator %q", item, keyValueSeparator) } if err := i.value.Set(value); err != nil { return err 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 3e7b049ea..f1c9d0ba8 100644 --- a/vendor/github.com/urfave/cli/v3/flag_slice_base.go +++ b/vendor/github.com/urfave/cli/v3/flag_slice_base.go @@ -9,9 +9,11 @@ import ( // SliceBase wraps []T to satisfy flag.Value type SliceBase[T any, C any, VC ValueCreator[T, C]] struct { - slice *[]T - hasBeenSet bool - value Value + slice *[]T + hasBeenSet bool + value Value + sliceSeparator string + disableSliceSeparator bool } func (i SliceBase[T, C, VC]) Create(val []T, p *[]T, c C) Value { @@ -33,6 +35,13 @@ func NewSliceBase[T any, C any, VC ValueCreator[T, C]](defaults ...T) *SliceBase } } +// configuration of slicing +func (i *SliceBase[T, C, VC]) setMultiValueParsingConfig(c multiValueParsingConfig) { + i.disableSliceSeparator = c.DisableSliceFlagSeparator + i.sliceSeparator = c.SliceFlagSeparator + tracef("set slice parsing config - slice separator '%s', disable separator:%v", i.sliceSeparator, i.disableSliceSeparator) +} + // Set parses the value and appends it to the list of values func (i *SliceBase[T, C, VC]) Set(value string) error { if !i.hasBeenSet { @@ -57,7 +66,8 @@ func (i *SliceBase[T, C, VC]) Set(value string) error { trimSpace = false } - for _, s := range flagSplitMultiValues(value) { + tracef("splitting slice value '%s', separator '%s', disable separator:%v", value, i.sliceSeparator, i.disableSliceSeparator) + for _, s := range flagSplitMultiValues(value, i.sliceSeparator, i.disableSliceSeparator) { if trimSpace { s = strings.TrimSpace(s) } diff --git a/vendor/github.com/urfave/cli/v3/godoc-current.txt b/vendor/github.com/urfave/cli/v3/godoc-current.txt index 46fb4d43a..c6f50b2ea 100644 --- a/vendor/github.com/urfave/cli/v3/godoc-current.txt +++ b/vendor/github.com/urfave/cli/v3/godoc-current.txt @@ -502,6 +502,8 @@ type Command struct { SliceFlagSeparator string `json:"sliceFlagSeparator"` // DisableSliceFlagSeparator is used to disable SliceFlagSeparator, the default is false DisableSliceFlagSeparator bool `json:"disableSliceFlagSeparator"` + // MapFlagKeyValueSeparator is used to customize the separator for MapFlag, the default is "=" + MapFlagKeyValueSeparator string `json:"mapFlagKeyValueSeparator"` // Boolean to enable short-option handling so user can combine several // single-character bool arguments into one // i.e. foobar -o -v -> foobar -ov diff --git a/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt b/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt index 4c9d877a6..5f3a0c364 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.4.7 -mkdocs-material==9.6.22 +mkdocs-git-revision-date-localized-plugin==1.5.0 +mkdocs-material==9.6.23 mkdocs==1.6.1 mkdocs-redirects==1.2.2 pygments==2.19.2 diff --git a/vendor/modules.txt b/vendor/modules.txt index 6628ebc45..22ee03856 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -377,7 +377,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.5.0 +# github.com/urfave/cli/v3 v3.6.0 ## explicit; go 1.22 github.com/urfave/cli/v3 # github.com/x448/float16 v0.8.4