peterbourgon / ff

Flags-first package for configuration
Apache License 2.0
1.37k stars 59 forks source link

WIP: Define FlagSet interface #62

Closed ebati closed 4 years ago

ebati commented 4 years ago

FlagSet methods have the same function signatures as flag.FlagSet, so flag.FlagSet can be used as FlagSet, for different flag libraries one can implement this interface. As an example AdaptPflag function converts pflag.FlagSet to FlagSet.

ebati commented 4 years ago

I updated the PR, added test with pflag.FlagSet but did not modify ffcli. Should ffcli also need to allow multiple FlagSet implementations?

peterbourgon commented 4 years ago

Should ffcli also need to allow multiple FlagSet implementations?

I guess it should be as simple as swapping *flag.FlagSet for ff.FlagSet, right? If so, yes please 👍

ebati commented 4 years ago

The usage func is set in parse (c.FlagSet.Usage = func (){...}) so I couldn't swap types.

Functions below are also not in FlagSet definition but we can add them: