aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2026-01-10Merge pull request #460 from pterjan/patch-2HEADmasterTomas Aschan
Fix for Go 1.24
2026-01-10Fix for Go 1.24Pascal Terjan
Go 1.24 no longer allows dynamic format string.
2025-10-07Merge pull request #453 from alimpfard/bool-flag-helpTomas Aschan
Show 'correct' explicit bool value syntax in help
2025-10-05Show 'correct' explicit bool value syntax in helpAli Mohammad Pur
2025-09-04Merge pull request #452 from thaJeztah/update_readmeTomas Aschan
README: update badges and minor linting fixes
2025-09-02README: update badges and minor linting fixesSebastiaan van Stijn
- Update build status badge to point to GitHub actions - Add a license badge - Update documentation badge to point to pkg.go.dev - Minor fixes in examples to make them runnable Signed-off-by: Sebastiaan van Stijn <[email protected]>
2025-09-02Merge pull request #448 from thaJeztah/fix_go_versionv1.0.10Tomas Aschan
remove uses of errors.Is, which requires go1.13, move go1.16/go1.21 tests to separate file
2025-09-02Merge pull request #447 from thaJeztah/fix_deprecation_commentTomas Aschan
fix deprecation comment for (FlagSet.)ParseErrorsWhitelist
2025-09-01Test on Go 1.12Tomas Aschan
Since 1.12 is what we specify in go.mod, and therefore implicitly is what we promise to work with, we should ensure that we don't introduce changes which break this promise (e.g. as 1bf832c6fec8a35a8c1d61e5fb14f5ce404197ef). Signed-off-by: Sebastiaan van Stijn <[email protected]>
2025-09-01move Func, BoolFunc, tests as they require go1.21Sebastiaan van Stijn
Commit 69bc3bd5b37fa90e994be9acecf7430269591713 added support for Func() and BoolFunc() to match stdlib. However, the Func method was added in [go1.16.0], and BoolFunc in [go1.21.0], so running the tests on older versions of Go would fail; docker run -it --rm -v ./:/pflag -w /pflag golang:1.21 sh -c 'go test -v ./...' # github.com/spf13/pflag [github.com/spf13/pflag.test] ./bool_func_test.go:86:28: cannot use stdFSet (type *flag.FlagSet) as type BoolFuncFlagSet in argument to runCase: *flag.FlagSet does not implement BoolFuncFlagSet (missing BoolFunc method) ./bool_func_test.go:113:21: undefined: io.Discard ./bool_func_test.go:116:28: cannot use stdFSet (type *flag.FlagSet) as type BoolFuncFlagSet in argument to runCase: *flag.FlagSet does not implement BoolFuncFlagSet (missing BoolFunc method) ./bool_func_test.go:139:7: undefined: errors.Is ./func_test.go:92:28: cannot use stdFSet (type *flag.FlagSet) as type FuncFlagSet in argument to runCase: *flag.FlagSet does not implement FuncFlagSet (missing Func method) ./func_test.go:119:21: undefined: io.Discard ./func_test.go:122:28: cannot use stdFSet (type *flag.FlagSet) as type FuncFlagSet in argument to runCase: *flag.FlagSet does not implement FuncFlagSet (missing Func method) ./func_test.go:145:7: undefined: errors.Is ./func_test.go:145:7: too many errors FAIL github.com/spf13/pflag [build failed] This patch moves the tests to a separate file that is not built for older versions of Go. [go1.16.0]: https://pkg.go.dev/[email protected]#Func [go1.21.0]: https://pkg.go.dev/[email protected]#BoolFunc Signed-off-by: Sebastiaan van Stijn <[email protected]>
2025-09-01remove uses of errors.Is, which requires go1.13Sebastiaan van Stijn
Commit 1bf832c6fec8a35a8c1d61e5fb14f5ce404197ef introduced the use of `errors.Is`, which was added in [go1.13], but the `go.mod` was not updated to reflect this, causing compile failures on go1.12: docker run -it --rm -v ./:/pflag -w /pflag golang:1.12 sh -c 'go test -v ./...' # github.com/spf13/pflag [github.com/spf13/pflag.test] ./flag.go:1190:7: undefined: errors.Is ./flag.go:1219:7: undefined: errors.Is ./bool_func_test.go:86:28: cannot use stdFSet (type *flag.FlagSet) as type BoolFuncFlagSet in argument to runCase: *flag.FlagSet does not implement BoolFuncFlagSet (missing BoolFunc method) ... As the error that is tested will not be wrapped, we can omit the `errors.Is`, and instead continue doing a straight comparison. [go1.13]: https://pkg.go.dev/[email protected]#Is Signed-off-by: Sebastiaan van Stijn <[email protected]>
2025-09-01fix deprecation comment for (FlagSet.)ParseErrorsWhitelistSebastiaan van Stijn
Commit 7412009ab0f29ad89cbc6625911a58c0618cf31e added back these types and marked them as deprecated, but did not use the correct format as documented in the [go documentation]. Deprecation comments should be in their own paragraph within the GoDoc, and start with `Deprecated:`, which is case-sensitive. Currently, the deprecation comment is not properly detected, and does not show up as deprecated on [pkg.go.dev]. This patch; - Fixes the deprecation comments to be in the right format. - Updates the GoDoc to use a "docs link" to refer to their replacement, which creates a link to those types on pkg.go.dev. - Adds back GoDoc for the deprecated functions to make sure the GoDoc is in the correct format and keep linters happy. [go documentation]: https://go.dev/doc/comment#deprecations [pkg.go.dev]: https://pkg.go.dev/github.com/spf13/[email protected]#ParseErrorsWhitelist Signed-off-by: Sebastiaan van Stijn <[email protected]>
2025-09-01Merge pull request #446 from spf13/fix-backwards-compatv1.0.9Tomas Aschan
fix: Restore ParseErrorsWhitelist name for now
2025-09-01fix: Restore ParseErrorsWhitelist name for nowTomas Aschan
This will be removed in a future release, but is reintroduced here to not break backwards compatibility.
2025-08-31Merge pull request #444 from spf13/reset-args-even-if-emptyv1.0.8Tomas Aschan
Reset args on re-parse even if empty
2025-08-30Merge pull request #443 from spf13/silence-errhelpTomas Aschan
fix: Don't print ErrHelp in ParseAll
2025-08-30Use errors.Is instead of equality checkTomas Aschan
2025-08-29Reset args on re-parse even if emptyreset-args-even-if-emptyTomas Aschan
This ensures fs.Args() returns the expected thing after every parse. Fixes #439.
2025-08-29Merge pull request #365 from vaguecoder/str2str-sortedTomas Aschan
Print Default Values of String-to-String in Sorted Order
2025-08-29Print Default Values of String-to-String in Sorted OrderBhargav Ravuri
Signed-off-by: Bhargav Ravuri <[email protected]>
2025-08-29fix: Don't print ErrHelp in ParseAllTomas Aschan
This is a fixup of #407 to ensure behavior of ExitOnError is consistent.
2025-08-29Merge pull request #407 from tmc/fix-errhelpTomas Aschan
flag: Emulate stdlib behavior and do not print ErrHelp
2025-08-29Merge branch 'master' into fix-errhelpTomas Aschan
2025-08-02Merge pull request #330 from pohly/copy-to-go-flagsetTomas Aschan
implement CopyToGoFlagSet
2025-08-02Merge pull request #438 from mologie/fix-time-default-textTomas Aschan
Omit zero time.Time default from usage line
2025-07-30add CopyToGoFlagSetPatrick Ohly
This is useful for programs which want to define some flags with pflag (for example, in external packages) but still need to use Go flag command line parsing to preserve backward compatibility with previous releases, in particular support for single-dash flags. Without this in pflag, such tools have to resort to copying via the public API, which leads to less useful help messages (type of basic values will be unknown).
2025-07-24Omit zero time.Time default from usage lineOliver Kuckertz
This was missed in #348, there previously was no way to omit the default value. Treating zero timestamp values as canary for absence of a default is in line with other flag types, e.g. zero ints.
2025-07-17Merge pull request #261 from dubrie/masterTomas Aschan
Switching from whitelist to Allowlist terminology. Fixes #294
2025-07-17Merge pull request #364 from vaguecoder/duplicate-errorTomas Aschan
Remove Redundant "Unknown-Flag" Error
2025-07-17Ensure output is written also from ParseAllTomas Aschan
2025-07-17Ensure output is written to correct streamTomas Aschan
2025-07-16Merge pull request #348 from max-frank/add-time-flag-supportv1.0.7Tomas Aschan
Add support for time.Time flags
2025-07-16Reduce duplication by forwarding to sibling functionsTomas Aschan
2025-07-16Don't export `TimeValue` (yet)Tomas Aschan
2025-07-14Remove unnecessary time test stderr dev null redirectMaximilian Frank
2025-07-14Use time.Time for expectations in time flag testsMaximilian Frank
2025-07-14Add support for time.Time flagsMaximilian Frank
2025-06-28Merge pull request #431 from LeGEC/430-fix-usage-message-for-func-flagsTomas Aschan
fix usage message for func flags, fix arguments order
2025-06-27fix discrepancy in order of arguments for Func() and BoolFunc() #433Georges Varouchas
for no good reason: the order of arguments would differ when calling pflag.BoolFuncP(...) and (*FlagSet).BoolFuncP(...) (same goes for Func() and FuncP()) in this commit: align all functions on stdlib's order fixes #433
2025-06-09fix help message for Func and BoolFunc flags #430Georges Varouchas
* have '.Type()' for boolfuncValue return "boolfunc" (dedicated value, which now makes it distinct from funcValue) * hide extra "(default )" by stating that "" should be treated as a zero value for a boolFlag note: - a boolfuncValue matches 'case boolFlag:', as it implements the boolFlag interface, - treating "" as a value which shouldn't trigger a "(default )" for a regular Bool flag does not look like a breaking change * hide extra "[=something]" for boolfuncValue * set default placeholder name for "boolfunc" and "func" flag types
2025-06-09minor: fix typos in commentsGeorges Varouchas
2025-06-01Merge pull request #409 from ShawnJeffersonWang/masterTomas Aschan
fix: correct argument length check in FlagSet.Parse
2025-05-24Merge pull request #429 from LeGEC/426-add-func-and-bool-funcTomas Aschan
add support for Func() and BoolFunc() #426
2025-05-22add support for Func() and BoolFunc() #426Georges Varouchas
Add support for two features which landed in the 'flag' package from the standard library: Func() and BoolFunc() and their two pflag specific versions: FuncP() and BoolFuncP() fixes #426
2025-05-15Merge pull request #418 from hujun-open/masterTomas Aschan
add support equivalent to golang flag.TextVar(), also fixes the test failure as described in #368
2025-05-14Merge pull request #424 from valdar/issue/423Tomas Aschan
fix #423 : Add helper function and some documentation to parse shorthand go test flags.
2025-05-14fix #423 : Add helper function and some documentation to parse shorthand go ↵Andrea Tarocchi
test flags.
2025-05-10- update text_test.go based on PR review commentsHu Jun
- return is missing in one error path of GetText(), fixed
2025-05-07Merge pull request #428 from co63oc/fix1Tomas Aschan
Fix typos
2025-05-06Fix typosco63oc