aboutsummaryrefslogtreecommitdiff
path: root/flag.go
diff options
context:
space:
mode:
authorTomas Aschan <[email protected]>2025-09-01 09:03:48 +0200
committerTomas Aschan <[email protected]>2025-09-01 09:03:48 +0200
commit7412009ab0f29ad89cbc6625911a58c0618cf31e (patch)
tree23b5f8a728b5e6c398f066535567a3583dd70d80 /flag.go
parentb9c16fa5ec31cd7339621b8d208bf4f2769486c4 (diff)
fix: Restore ParseErrorsWhitelist name for now
This will be removed in a future release, but is reintroduced here to not break backwards compatibility.
Diffstat (limited to 'flag.go')
-rw-r--r--flag.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/flag.go b/flag.go
index dbb3907..eeed1e9 100644
--- a/flag.go
+++ b/flag.go
@@ -143,6 +143,10 @@ type ParseErrorsAllowlist struct {
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
// for the FlagSet (e.g. making '-' and '_' equivalent).
type NormalizedName string
@@ -161,6 +165,10 @@ type FlagSet struct {
// ParseErrorsAllowlist is used to configure an allowlist of errors
ParseErrorsAllowlist ParseErrorsAllowlist
+ // DEPRECATED: please use ParseErrorsAllowlist instead
+ // This field will be removed in a future release
+ ParseErrorsWhitelist ParseErrorsAllowlist
+
name string
parsed bool
actual map[NormalizedName]*Flag
@@ -984,6 +992,8 @@ func (f *FlagSet) parseLongArg(s string, args []string, fn parseFunc) (a []strin
case name == "help":
f.usage()
return a, ErrHelp
+ case f.ParseErrorsWhitelist.UnknownFlags:
+ fallthrough
case f.ParseErrorsAllowlist.UnknownFlags:
// --unknown=unknownval arg ...
// we do not want to lose arg in this case
@@ -1042,6 +1052,8 @@ func (f *FlagSet) parseSingleShortArg(shorthands string, args []string, fn parse
f.usage()
err = ErrHelp
return
+ case f.ParseErrorsWhitelist.UnknownFlags:
+ fallthrough
case f.ParseErrorsAllowlist.UnknownFlags:
// '-f=arg arg ...'
// we do not want to lose arg in this case