| Age | Commit message (Collapse) | Author |
|
Go 1.24 no longer allows dynamic format string.
|
|
|
|
remove uses of errors.Is, which requires go1.13, move go1.16/go1.21 tests to separate file
|
|
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]>
|
|
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
|
|
|
|
This ensures fs.Args() returns the expected thing after every parse.
Fixes #439.
|
|
This is a fixup of #407 to ensure behavior of ExitOnError is consistent.
|
|
|
|
Switching from whitelist to Allowlist terminology. Fixes #294
|
|
Remove Redundant "Unknown-Flag" Error
|
|
|
|
|
|
* 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
|
|
fix #423 : Add helper function and some documentation to parse shorthand go test flags.
|
|
test flags.
|
|
This allows callers to differentiate between error types without having
to parse the error message string.
|
|
|
|
Signed-off-by: shawn <[email protected]>
|
|
|
|
Signed-off-by: Bhargav Ravuri <[email protected]>
|
|
|
|
* Rename out() to Output()
This brings behavior inline with go's flag library, and allows for
printing output directly to whatever the current FlagSet is using for
output. This change will make it easier to correctly emit output to
stdout or stderr (e.g. a user has requested a help screen, which
should emit to stdout since it's the desired outcome).
* improve compat. with pkg/flag by adding Name()
pkg/flag has a public `Name()` function, which returns the name of the
flag set when called. This commit adds that function, as well as a
test for it.
* Streamline testing Name()
Testing `Name()` will move into its own explicit test, instead of
running inline during `TestAddFlagSet()`.
Co-authored-by: Chloe Kudryavtsev <[email protected]>
Co-authored-by: Chloe Kudryavtsev <[email protected]>
|
|
Implement SliceValue for better list semantics
|
|
|
|
|
|
Signed-off-by: David Schneider <[email protected]>
|
|
Signed-off-by: Oren Shomron <[email protected]>
|
|
Based on patch suggested here: https://github.com/spf13/cobra/issues/597#issuecomment-385984076
|
|
|
|
They have to explicitly unhide a deprecated flag to keep the current behavior.
|
|
* make GoFlagSets.Parsed() true after pflag.Parse
some third part lib such as glog use go flag package, and its some
actions depends on if goflag.Parsed().
* add test case for goflag.CommandLine.Parsed()
* add comment to goflag.CommandLine.Parsed test case
|
|
* add ability to ignore unknown flags
* add testcases
* add 2 more patterns to the testcase
* handle --unknownflag=val arg and -u=val arg scenario
* add ParseErrorsWhiteList to extend error handling during parsing
|
|
* Add multiline wrapping support
With reference to golang/go#20799, pflag now will respect newline in usage string and do wrap accordingly. Also add test cases for testing
* Break at \n only if \n pos<wrap
|
|
|
|
|
|
|
|
Related to https://github.com/spf13/cobra/issues/521
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|