jessevdk / go-flags

go command line option parser
http://godoc.org/github.com/jessevdk/go-flags
BSD 3-Clause "New" or "Revised" License
2.59k stars 308 forks source link

Use encoding.TextMarshaler/encoding.TextUnmarshaler if present #413

Open drshriveer opened 1 month ago

drshriveer commented 1 month ago

Background:

In order to parse custom flag types it is currently necessary to implement the flags.Unmarshaler and optionally the flags.Marshaler interface. That interface is specific to this library, but many types already make use of encoding.TextMarshaler and encoding.TextUnmarshaler which is a bit more standardized. It is cumbersome, and sometimes impossible when you don't own the code, to implement both interfaces. Thus this PR allows adds the ability to marshal flags by those interfaces.

Changes: