pflag
pflag copied to clipboard
Allow case-insensitive long flag names, perhaps as an option
It would be great if pflag
could accept case-insensitive long flag names, perhaps as an option, so that it would treat variations like --baseUrl
, --baseURL
and --baseurl
as one and the same.
A discussion that led to this feature request is available at spf13/hugo/issues/959
Many thanks!
Since you are using hugo (which I believe in turn uses spf13/cobra and spf13/pflag) you can check out the "normalized name" support. It allows you to write your own custom function which in your case could translate all flags to lowercase.
https://github.com/spf13/cobra/blob/master/command.go#L158 https://github.com/spf13/pflag/blob/master/flag.go#L184
It is being used in kubernetes to turn flags_like_this
into flags-like-this
so we have a consistent -