alvaroloes / enumer

A Go tool to auto generate methods for your enums
Other
478 stars 111 forks source link

Add support for several new transformation options. #31

Closed josephtfrank closed 5 years ago

josephtfrank commented 6 years ago

This change adds support for additional transformations of the name. The new values are lower, upper, kebabu, and snakeu.

Options have been added to handle more permissive translation from a string to a value. The -ignorecase option ignores case when comparing the input string to the enum name. The -numeric option allows translation of numbers in input strings in addition to the enum names.

Finally, an option has been added to specify a zero value enum which is represented by an empty string. The empty string is used when generating a string from a value, or when converting a string to a value.

mvrhov commented 5 years ago

Hey @alvaroloes, can we get this one merged please?

dmarkham commented 5 years ago

I have merged this in my new and supported version that is a drop in replacement. A long with go mod support. If your interested. https://github.com/dmarkham/enumer

alvaroloes commented 5 years ago

@josephtfrank @mvrhov Thank you, Joe, for submitting this PR, but it has the same problems as https://github.com/alvaroloes/enumer/pull/38

In the same reasoning path, I would say that the numeric option is very very specific and falls out of the scope of Enumer, whose purpose is to auto-generate String representations of enum values using the variable name, not the value. The numeric option is mixing both concerns, and that probably cause confusions to the people.

alvaroloes commented 5 years ago

@josephtfrank With the addition of -linecomment, adding more transformations is now a bit superfluous so I would prefer the user interface as small as possible. Thanks a lot for the PR! I'll close it now.