-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add exported functions to preserve pkg/flag
compatibility
#220
Conversation
This brings behavior inline with go's flag library, and allows for printing output directly to whatever the current FlagSet is using for output. This change will make it easier to correctly emit output to stdout or stderr (e.g. a user has requested a help screen, which should emit to stdout since it's the desired outcome).
go/flag in go 1.13 has a public Output() function and a Name() function - change out() to Output() (adjusting the rest of the file) - add Name() and tests for it From: @mckern (spf13#220) re: out/Output: This brings behavior inline with go's flag library, and allows for printing output directly to whatever the current FlagSet is using for output. This change will make it easier to correctly emit output to stdout or stderr (e.g. a user has requested a help screen, which should emit to stdout since it's the desired outcome).
pkg/flag has a public `Name()` function, which returns the name of the flag set when called. This commit adds that function, as well as a test for it.
pkg/flag
compatibility
I'd prefer if the |
Oh it definitely runs (I induced a failure state to check). It doesn't look like the standard is consistently applied and I'm not sure why some tests end up as public functions and some don't:
Looks like more of them are public than not though, so yeah, let's go with that. |
Testing `Name()` will move into its own explicit test, instead of running inline during `TestAddFlagSet()`. Co-authored-by: Chloe Kudryavtsev <toast@toast.cafe>
/cc @eparis I think we've worked it out, if you're still available for review? Please & thank you! |
Ping @eparis ? |
Ping @eparis and/or @therealmitchconnors ? |
just 3cents, I am kind of waiting for that to be in pflag since literally years. (had sibling issue #230 opened here) |
Thank you @therealmitchconnors ! |
thanks @therealmitchconnors 🎉 ! |
These changes bring behavior inline with go's
flag
library, and allows for printing output directly to whatever the current FlagSet is using for output and retrieving a given FlagSet's name. These changes will make it easier to correctly emit output to stdout or stderr (e.g. a user has requested a help screen, which should emit to stdout since it's the desired outcome).(This PR has also pulled in #241, since @5paceToast and I were clearly working in the same direction here)
example for
Out()
:example for
Name()
: