pflag icon indicating copy to clipboard operation
pflag copied to clipboard

`CountVar` doesn't support default value setting

Open ZhouXing19 opened this issue 1 year ago • 1 comments

When setting a count flag, the default value setting is not supported -- FlagSet.CountVarP() or FlagSet.CountVar() only takes name and usage as parameters. Weirdly, it is noted in the comment that default value is allowed.

https://github.com/spf13/pflag/blob/d5e0c0615acee7028e1e2740a11102313be88de1/count.go#L47-L58

ZhouXing19 avatar Sep 18 '23 19:09 ZhouXing19

IMHO, the only way to preserve a backard compatibility would be to extend these methods with some ...Option parameter. One such option could support adding a default value.

fredbi avatar Oct 03 '23 06:10 fredbi