Conversation
Signed-off-by: Bhargav Ravuri <vaguecoder0to.n@gmail.com>
Signed-off-by: shawn <xw2002121@gmail.com>
…failure as described in spf13#368
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
add github actions
…alue-for-generic-value-type Fix defaultIsZeroValue check for generic Value types
Add tests to ensure invalid arguments and unknown flag error messages don't change.
This allows callers to differentiate between error types without having to parse the error message string.
feat: Use structs for errors returned by pflag.
Fix typos
- return is missing in one error path of GetText(), fixed
…horthand go test flags.
fix spf13#423 : Add helper function and some documentation to parse shorthand go test flags.
add support equivalent to golang flag.TextVar(), also fixes the test failure as described in spf13#368
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 spf13#426
add support for Func() and BoolFunc() spf13#426
flag: Emulate stdlib behavior and do not print ErrHelp
This is a fixup of spf13#407 to ensure behavior of ExitOnError is consistent.
Signed-off-by: Bhargav Ravuri <vaguecoder0to.n@gmail.com>
Print Default Values of String-to-String in Sorted Order
This ensures fs.Args() returns the expected thing after every parse. Fixes spf13#439.
fix: Don't print ErrHelp in ParseAll
Reset args on re-parse even if empty
This will be removed in a future release, but is reintroduced here to not break backwards compatibility.
fix: Restore ParseErrorsWhitelist name for now
Commit 7412009 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/pflag@v1.0.9#ParseErrorsWhitelist Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Commit 1bf832c 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/errors@go1.13#Is Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Commit 69bc3bd 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/flag@go1.16.0#Func [go1.21.0]: https://pkg.go.dev/flag@go1.21.0#BoolFunc Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
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 1bf832c). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
fix deprecation comment for (FlagSet.)ParseErrorsWhitelist
remove uses of errors.Is, which requires go1.13, move go1.16/go1.21 tests to separate file
8aed940 to
e312ba0
Compare
Pull Request Test Coverage Report for Build 19162697504Details
💛 - Coveralls |
1eaf97e to
2a8de14
Compare
2a8de14 to
44262a6
Compare
44262a6 to
d307325
Compare
d307325 to
fab9c2c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BoolFuncspf13/pflag#430.Func()and.BoolFunc()spf13/pflag#433TimeValue(yet)