iniflags icon indicating copy to clipboard operation
iniflags copied to clipboard

pflag?

Open joncrlsn opened this issue 10 years ago • 3 comments

I like the way this library goes about solving the go config issue.

I suspect this could this be made to work with pflag? https://github.com/ogier/pflag. Do you see it being a real simple change if I forked this project (or if you added the feature), or do you foresee some messiness?

pflag mimics the standard flag library but adds some constructors for supplying both 1-character flags and multi-character flags (like --help).

Thanks!

  • Jon

joncrlsn avatar Jan 26 '15 18:01 joncrlsn

It would be really cool if Go supported try/except imports like in Python, but currently it does not, so I see no easy way to make the library work with native flags and pflag if it is installed, what solution do you have in mind ?

vharitonsky avatar Jan 29 '15 17:01 vharitonsky

I don't have any good solutions. Sorry.

joncrlsn avatar Feb 04 '15 22:02 joncrlsn

Most of the logic in the "flag" package is actually wrapped in the "CommandLine" singleton (instance of FlagSet), so if you had a FlagSet interface that both flag and pflag support (or at least pflag can be wrapped to support), then I imagine the code could be adjusted to support both cases.

This would mean replacing usage of convenience methods which assume we are talking about the command line flag set, such as flag.Lookup()

ted537 avatar Dec 20 '22 15:12 ted537