| Age | Commit message (Collapse) | Author |
|
Fix for Go 1.24
|
|
Go 1.24 no longer allows dynamic format string.
|
|
Show 'correct' explicit bool value syntax in help
|
|
|
|
README: update badges and minor linting fixes
|
|
- 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]>
|
|
remove uses of errors.Is, which requires go1.13, move go1.16/go1.21 tests to separate file
|
|
fix deprecation comment for (FlagSet.)ParseErrorsWhitelist
|
|
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]>
|
|
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]>
|
|
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]>
|
|
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]>
|
|
fix: Restore ParseErrorsWhitelist name for now
|
|
This will be removed in a future release, but is reintroduced here to not break backwards compatibility.
|
|
Reset args on re-parse even if empty
|
|
fix: Don't print ErrHelp in ParseAll
|
|
|
|
This ensures fs.Args() returns the expected thing after every parse.
Fixes #439.
|
|
Print Default Values of String-to-String in Sorted Order
|
|
Signed-off-by: Bhargav Ravuri <[email protected]>
|
|
This is a fixup of #407 to ensure behavior of ExitOnError is consistent.
|
|
flag: Emulate stdlib behavior and do not print ErrHelp
|
|
|
|
implement CopyToGoFlagSet
|
|
Omit zero time.Time default from usage line
|
|
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).
|
|
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.
|
|
Switching from whitelist to Allowlist terminology. Fixes #294
|
|
Remove Redundant "Unknown-Flag" Error
|
|
|
|
|
|
Add support for time.Time flags
|
|
|
|
|
|
|
|
|
|
|
|
fix usage message for func flags, fix arguments order
|
|
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
|
|
* 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
|
|
|
|
fix: correct argument length check in FlagSet.Parse
|
|
add support for Func() and BoolFunc() #426
|
|
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
|
|
add support equivalent to golang flag.TextVar(), also fixes the test failure as described in #368
|
|
fix #423 : Add helper function and some documentation to parse shorthand go test flags.
|
|
test flags.
|
|
- return is missing in one error path of GetText(), fixed
|
|
Fix typos
|
|
|