Update module github.com/spf13/pflag to v1.0.9

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
renovate[bot]
2025-09-01 16:22:21 +00:00
committed by GitHub
parent 6d210dd074
commit 11dedf8b4a
7 changed files with 80 additions and 14 deletions

2
go.mod
View File

@@ -15,7 +15,7 @@ require (
github.com/opencontainers/image-tools v1.0.0-rc3 github.com/opencontainers/image-tools v1.0.0-rc3
github.com/sirupsen/logrus v1.9.3 github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.9.1 github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.7 github.com/spf13/pflag v1.0.9
github.com/stretchr/testify v1.11.1 github.com/stretchr/testify v1.11.1
go.podman.io/common v0.0.0-20250826054041-6e4bed3c9118 go.podman.io/common v0.0.0-20250826054041-6e4bed3c9118
go.podman.io/image/v5 v5.36.1-0.20250820085751-a13b38f45723 go.podman.io/image/v5 v5.36.1-0.20250820085751-a13b38f45723

4
go.sum
View File

@@ -227,8 +227,8 @@ github.com/smallstep/pkcs7 v0.1.1/go.mod h1:dL6j5AIz9GHjVEBTXtW+QliALcgM19RtXaTe
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/pflag v1.0.7 h1:vN6T9TfwStFPFM5XzjsvmzZkLuaLX+HS+0SeFLRgU6M= github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
github.com/spf13/pflag v1.0.7/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stefanberger/go-pkcs11uri v0.0.0-20230803200340-78284954bff6 h1:pnnLyeX7o/5aX8qUQ69P/mLojDqwda8hFOCBTmP/6hw= github.com/stefanberger/go-pkcs11uri v0.0.0-20230803200340-78284954bff6 h1:pnnLyeX7o/5aX8qUQ69P/mLojDqwda8hFOCBTmP/6hw=
github.com/stefanberger/go-pkcs11uri v0.0.0-20230803200340-78284954bff6/go.mod h1:39R/xuhNgVhi+K0/zst4TLrJrVmbm6LVgl4A0+ZFS5M= github.com/stefanberger/go-pkcs11uri v0.0.0-20230803200340-78284954bff6/go.mod h1:39R/xuhNgVhi+K0/zst4TLrJrVmbm6LVgl4A0+ZFS5M=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

View File

@@ -137,12 +137,16 @@ const (
PanicOnError PanicOnError
) )
// ParseErrorsWhitelist defines the parsing errors that can be ignored // ParseErrorsAllowlist defines the parsing errors that can be ignored
type ParseErrorsWhitelist struct { type ParseErrorsAllowlist struct {
// UnknownFlags will ignore unknown flags errors and continue parsing rest of the flags // UnknownFlags will ignore unknown flags errors and continue parsing rest of the flags
UnknownFlags bool UnknownFlags bool
} }
// DEPRECATED: please use ParseErrorsAllowlist instead
// This type will be removed in a future release
type ParseErrorsWhitelist = ParseErrorsAllowlist
// NormalizedName is a flag name that has been normalized according to rules // NormalizedName is a flag name that has been normalized according to rules
// for the FlagSet (e.g. making '-' and '_' equivalent). // for the FlagSet (e.g. making '-' and '_' equivalent).
type NormalizedName string type NormalizedName string
@@ -158,8 +162,12 @@ type FlagSet struct {
// help/usage messages. // help/usage messages.
SortFlags bool SortFlags bool
// ParseErrorsWhitelist is used to configure a whitelist of errors // ParseErrorsAllowlist is used to configure an allowlist of errors
ParseErrorsWhitelist ParseErrorsWhitelist ParseErrorsAllowlist ParseErrorsAllowlist
// DEPRECATED: please use ParseErrorsAllowlist instead
// This field will be removed in a future release
ParseErrorsWhitelist ParseErrorsAllowlist
name string name string
parsed bool parsed bool
@@ -928,7 +936,6 @@ func VarP(value Value, name, shorthand, usage string) {
// returns the error. // returns the error.
func (f *FlagSet) fail(err error) error { func (f *FlagSet) fail(err error) error {
if f.errorHandling != ContinueOnError { if f.errorHandling != ContinueOnError {
fmt.Fprintln(f.Output(), err)
f.usage() f.usage()
} }
return err return err
@@ -986,6 +993,8 @@ func (f *FlagSet) parseLongArg(s string, args []string, fn parseFunc) (a []strin
f.usage() f.usage()
return a, ErrHelp return a, ErrHelp
case f.ParseErrorsWhitelist.UnknownFlags: case f.ParseErrorsWhitelist.UnknownFlags:
fallthrough
case f.ParseErrorsAllowlist.UnknownFlags:
// --unknown=unknownval arg ... // --unknown=unknownval arg ...
// we do not want to lose arg in this case // we do not want to lose arg in this case
if len(split) >= 2 { if len(split) >= 2 {
@@ -1044,6 +1053,8 @@ func (f *FlagSet) parseSingleShortArg(shorthands string, args []string, fn parse
err = ErrHelp err = ErrHelp
return return
case f.ParseErrorsWhitelist.UnknownFlags: case f.ParseErrorsWhitelist.UnknownFlags:
fallthrough
case f.ParseErrorsAllowlist.UnknownFlags:
// '-f=arg arg ...' // '-f=arg arg ...'
// we do not want to lose arg in this case // we do not want to lose arg in this case
if len(shorthands) > 2 && shorthands[1] == '=' { if len(shorthands) > 2 && shorthands[1] == '=' {
@@ -1158,12 +1169,12 @@ func (f *FlagSet) Parse(arguments []string) error {
} }
f.parsed = true f.parsed = true
f.args = make([]string, 0, len(arguments))
if len(arguments) == 0 { if len(arguments) == 0 {
return nil return nil
} }
f.args = make([]string, 0, len(arguments))
set := func(flag *Flag, value string) error { set := func(flag *Flag, value string) error {
return f.Set(flag.Name, value) return f.Set(flag.Name, value)
} }
@@ -1174,7 +1185,10 @@ func (f *FlagSet) Parse(arguments []string) error {
case ContinueOnError: case ContinueOnError:
return err return err
case ExitOnError: case ExitOnError:
fmt.Println(err) if errors.Is(err, ErrHelp) {
os.Exit(0)
}
fmt.Fprintln(f.Output(), err)
os.Exit(2) os.Exit(2)
case PanicOnError: case PanicOnError:
panic(err) panic(err)
@@ -1200,6 +1214,10 @@ func (f *FlagSet) ParseAll(arguments []string, fn func(flag *Flag, value string)
case ContinueOnError: case ContinueOnError:
return err return err
case ExitOnError: case ExitOnError:
if errors.Is(err, ErrHelp) {
os.Exit(0)
}
fmt.Fprintln(f.Output(), err)
os.Exit(2) os.Exit(2)
case PanicOnError: case PanicOnError:
panic(err) panic(err)

View File

@@ -8,6 +8,7 @@ import (
goflag "flag" goflag "flag"
"reflect" "reflect"
"strings" "strings"
"time"
) )
// go test flags prefixes // go test flags prefixes
@@ -113,6 +114,38 @@ func (f *FlagSet) AddGoFlagSet(newSet *goflag.FlagSet) {
f.addedGoFlagSets = append(f.addedGoFlagSets, newSet) f.addedGoFlagSets = append(f.addedGoFlagSets, newSet)
} }
// CopyToGoFlagSet will add all current flags to the given Go flag set.
// Deprecation remarks get copied into the usage description.
// Whenever possible, a flag gets added for which Go flags shows
// a proper type in the help message.
func (f *FlagSet) CopyToGoFlagSet(newSet *goflag.FlagSet) {
f.VisitAll(func(flag *Flag) {
usage := flag.Usage
if flag.Deprecated != "" {
usage += " (DEPRECATED: " + flag.Deprecated + ")"
}
switch value := flag.Value.(type) {
case *stringValue:
newSet.StringVar((*string)(value), flag.Name, flag.DefValue, usage)
case *intValue:
newSet.IntVar((*int)(value), flag.Name, *(*int)(value), usage)
case *int64Value:
newSet.Int64Var((*int64)(value), flag.Name, *(*int64)(value), usage)
case *uintValue:
newSet.UintVar((*uint)(value), flag.Name, *(*uint)(value), usage)
case *uint64Value:
newSet.Uint64Var((*uint64)(value), flag.Name, *(*uint64)(value), usage)
case *durationValue:
newSet.DurationVar((*time.Duration)(value), flag.Name, *(*time.Duration)(value), usage)
case *float64Value:
newSet.Float64Var((*float64)(value), flag.Name, *(*float64)(value), usage)
default:
newSet.Var(flag.Value, flag.Name, usage)
}
})
}
// ParseSkippedFlags explicitly Parses go test flags (i.e. the one starting with '-test.') with goflag.Parse(), // ParseSkippedFlags explicitly Parses go test flags (i.e. the one starting with '-test.') with goflag.Parse(),
// since by default those are skipped by pflag.Parse(). // since by default those are skipped by pflag.Parse().
// Typical usage example: `ParseGoTestFlags(os.Args[1:], goflag.CommandLine)` // Typical usage example: `ParseGoTestFlags(os.Args[1:], goflag.CommandLine)`
@@ -125,3 +158,4 @@ func ParseSkippedFlags(osArgs []string, goFlagSet *goflag.FlagSet) error {
} }
return goFlagSet.Parse(skippedFlags) return goFlagSet.Parse(skippedFlags)
} }

View File

@@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"encoding/csv" "encoding/csv"
"fmt" "fmt"
"sort"
"strings" "strings"
) )
@@ -62,8 +63,15 @@ func (s *stringToStringValue) Type() string {
} }
func (s *stringToStringValue) String() string { func (s *stringToStringValue) String() string {
keys := make([]string, 0, len(*s.value))
for k := range *s.value {
keys = append(keys, k)
}
sort.Strings(keys)
records := make([]string, 0, len(*s.value)>>1) records := make([]string, 0, len(*s.value)>>1)
for k, v := range *s.value { for _, k := range keys {
v := (*s.value)[k]
records = append(records, k+"="+v) records = append(records, k+"="+v)
} }

View File

@@ -48,7 +48,13 @@ func (d *timeValue) Type() string {
return "time" return "time"
} }
func (d *timeValue) String() string { return d.Time.Format(time.RFC3339Nano) } func (d *timeValue) String() string {
if d.Time.IsZero() {
return ""
} else {
return d.Time.Format(time.RFC3339Nano)
}
}
// GetTime return the time value of a flag with the given name // GetTime return the time value of a flag with the given name
func (f *FlagSet) GetTime(name string) (time.Time, error) { func (f *FlagSet) GetTime(name string) (time.Time, error) {

2
vendor/modules.txt vendored
View File

@@ -287,7 +287,7 @@ github.com/smallstep/pkcs7/internal/legacy/x509
# github.com/spf13/cobra v1.9.1 # github.com/spf13/cobra v1.9.1
## explicit; go 1.15 ## explicit; go 1.15
github.com/spf13/cobra github.com/spf13/cobra
# github.com/spf13/pflag v1.0.7 # github.com/spf13/pflag v1.0.9
## explicit; go 1.12 ## explicit; go 1.12
github.com/spf13/pflag github.com/spf13/pflag
# github.com/stefanberger/go-pkcs11uri v0.0.0-20230803200340-78284954bff6 # github.com/stefanberger/go-pkcs11uri v0.0.0-20230803200340-78284954bff6