Anyflag
Anyflag is implementation of Cobra Value
and SliceValue
interfaces using Go Generics.
It allows you to use any type as a flag value.
Installation
go get github.com/mmatczuk/anyflag
Usage
var ba *url.Userinfo
cmd.Flags().VarP(anyflag.NewValue[*url.Userinfo](nil, &ba, parseBasicAuth), "basic-auth", "", "basic auth")
var bas []*url.Userinfo
cmd.Flags().VarP(anyflag.NewSliceValue[*url.Userinfo](nil, &bas, parseBasicAuth), "basic-auth", "", "basic auth")
See full running example in example_test.go.
License
This project is based on spf13/pflag licensed under the BSD 3-Clause “New” or “Revised” License