pflag
pflag copied to clipboard
Drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
The defaultIsZeroValue() method was erroneously assuming that all types that implement IsBoolFlag() were bools - regardless of the return value of IsBoolFlag(). Fixes #360
I've implemented a custom `Value` type for managing generic data. Everything works as it should, but the flags always show a default in their usage string regardless of whether they...
Using Go generics it's possible to greatly streamline the process of binding custom value types. I have created a library as a POC [github.com/mmatczuk/anyflag](https://github.com/mmatczuk/anyflag). To work with it users have...
Persistent flags (`shorthand`) of cmd's parents conflict with cmd's shorthand flags. We faced this issue multiple time within nerdctl (https://github.com/containerd/nerdctl/issues/1334) . This idea of this PR is to ignore the...
All standard library flags since Go 1.2 implement the Getter interface and I think that pflag should do it too. https://github.com/golang/go/blob/master/src/flag/flag.go#L306 ```go // Getter is an interface that allows the...
`FlagSet.ParseErrorsWhitelist.UnknownFlags` ignores unknown flags, but throws away them. I want `pflag` just skip them and pass them to `Args()`. Input: ``` --known-flag known-flag-value --unknown-flag arg0 arg1 arg2 ``` Current output...
Currently if you add a default value through `NoOptDefVal` or `DefValue`, it gets printed in the help/usage message. ``` fs.StringVarP(&cs.Password, "password", "p", "default", "the password for a remote user supplied...
Fix #204 This change allows a user to set `Flag.DefValue` to an empty string to suppress the "(default %v)" printed in the usage line for custom `Value` types that have...
Reproducer: ``` package main import "os" import flag "github.com/spf13/pflag" func main() { fs := flag.NewFlagSet("myprog", flag.ExitOnError) fs.Parse(os.Args[1:]) } ``` Example: ``` $ go run main.go --bogus unknown flag: --bogus Usage...
Promote reuse and make it convenient for users to create and add these Value types hand-crafted pflag.Flag structs when the helper functions can't be used and the raw pflag.Flag value...