diff options
| author | Tomas Aschan <[email protected]> | 2025-07-17 11:32:04 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-17 11:32:04 +0200 |
| commit | c78f730fb023e4012c4097b24408867cd5c5bdde (patch) | |
| tree | 71e39980c518afe645c279857d1f3377b9b50ff3 | |
| parent | c2fd743bf6955c7ac319714a7855bd184cc58af7 (diff) | |
| parent | 0aa4171c4229535ef4247b9283732fb21867b08e (diff) | |
Merge pull request #261 from dubrie/master
Switching from whitelist to Allowlist terminology. Fixes #294
| -rw-r--r-- | flag.go | 12 | ||||
| -rw-r--r-- | flag_test.go | 2 |
2 files changed, 7 insertions, 7 deletions
@@ -137,8 +137,8 @@ const ( PanicOnError ) -// ParseErrorsWhitelist defines the parsing errors that can be ignored -type ParseErrorsWhitelist struct { +// ParseErrorsAllowlist defines the parsing errors that can be ignored +type ParseErrorsAllowlist struct { // UnknownFlags will ignore unknown flags errors and continue parsing rest of the flags UnknownFlags bool } @@ -158,8 +158,8 @@ type FlagSet struct { // help/usage messages. SortFlags bool - // ParseErrorsWhitelist is used to configure a whitelist of errors - ParseErrorsWhitelist ParseErrorsWhitelist + // ParseErrorsAllowlist is used to configure an allowlist of errors + ParseErrorsAllowlist ParseErrorsAllowlist name string parsed bool @@ -984,7 +984,7 @@ func (f *FlagSet) parseLongArg(s string, args []string, fn parseFunc) (a []strin case name == "help": f.usage() return a, ErrHelp - case f.ParseErrorsWhitelist.UnknownFlags: + case f.ParseErrorsAllowlist.UnknownFlags: // --unknown=unknownval arg ... // we do not want to lose arg in this case if len(split) >= 2 { @@ -1042,7 +1042,7 @@ func (f *FlagSet) parseSingleShortArg(shorthands string, args []string, fn parse f.usage() err = ErrHelp return - case f.ParseErrorsWhitelist.UnknownFlags: + case f.ParseErrorsAllowlist.UnknownFlags: // '-f=arg arg ...' // we do not want to lose arg in this case if len(shorthands) > 2 && shorthands[1] == '=' { diff --git a/flag_test.go b/flag_test.go index ead0518..2df3ea2 100644 --- a/flag_test.go +++ b/flag_test.go @@ -451,7 +451,7 @@ func testParseWithUnknownFlags(f *FlagSet, t *testing.T) { if f.Parsed() { t.Error("f.Parse() = true before Parse") } - f.ParseErrorsWhitelist.UnknownFlags = true + f.ParseErrorsAllowlist.UnknownFlags = true f.BoolP("boola", "a", false, "bool value") f.BoolP("boolb", "b", false, "bool2 value") |
