Parse string map values
In cobra, I have a use case where I want to parse a string map from command line as follow:
$ mycommand --string-map-option "a=b,c=d"
I haven't seen any method into pflag to parse the result as map[string]string.
For now, I have implemented in my project a basic version that satisfies pflag.Value interface. I use FlagSet.Var() method to use the previous value and it's working well.
It will be interesting to directly have this parser into pflag package. I think this flag parser can be helpful to the community. If you are OK with this idea, I can propose a Pull Request based on my current implementation.
We would like this. I think there are common use-cases for both string-> string and string -> int flags.
I also have a need for this.
FYI: @eparis if you feel the work accomplished in #133 properly addresses the OP issue here this could probably be closed
Reading this thread now, I have a question: In case of -flag a=x,a=y the variable p(map[string]string) only has a=y and ignores a=x which I think is a bad user experience. Is this expected? @tamalsaha @eparis Any suggestions to avoid this?