Add exported functions to preserve pkg/flag compatibility#220
Merged
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).
This was referenced Feb 17, 2020
CosmicToast
pushed a commit
to CosmicToast/pflag
that referenced
this pull request
Feb 19, 2020
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 |
Author
|
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>
Author
|
/cc @eparis I think we've worked it out, if you're still available for review? Please & thank you! |
Author
|
Ping @eparis ? |
Author
|
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) |
therealmitchconnors
approved these changes
May 4, 2020
|
Thank you @therealmitchconnors ! |
Author
|
thanks @therealmitchconnors 🎉 ! |
algitbot
pushed a commit
to alpinelinux/build-server-status
that referenced
this pull request
Jan 30, 2025
This MR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/spf13/pflag](https://github.com/spf13/pflag) | require | patch | `v1.0.5` -> `v1.0.6` | --- ### Release Notes <details> <summary>spf13/pflag (github.com/spf13/pflag)</summary> ### [`v1.0.6`](https://github.com/spf13/pflag/releases/tag/v1.0.6) [Compare Source](spf13/pflag@v1.0.5...v1.0.6) #### What's Changed - Add exported functions to preserve `pkg/flag` compatibility by [@​mckern](https://github.com/mckern) in spf13/pflag#220 - remove dead code for checking error nil by [@​yashbhutwala](https://github.com/yashbhutwala) in spf13/pflag#282 - Add IPNetSlice and unit tests by [@​rpothier](https://github.com/rpothier) in spf13/pflag#170 - allow for blank ip addresses by [@​duhruh](https://github.com/duhruh) in spf13/pflag#316 - add github actions by [@​sagikazarmark](https://github.com/sagikazarmark) in spf13/pflag#419 #### New Contributors - [@​mckern](https://github.com/mckern) made their first contribution in spf13/pflag#220 - [@​yashbhutwala](https://github.com/yashbhutwala) made their first contribution in spf13/pflag#282 - [@​rpothier](https://github.com/rpothier) made their first contribution in spf13/pflag#170 - [@​duhruh](https://github.com/duhruh) made their first contribution in spf13/pflag#316 - [@​sagikazarmark](https://github.com/sagikazarmark) made their first contribution in spf13/pflag#419 **Full Changelog**: spf13/pflag@v1.0.5...v1.0.6 </details> --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xMDYuMCIsInVwZGF0ZWRJblZlciI6IjM5LjEwNi4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=--> See merge request alpine/infra/build-server-status!19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These changes bring behavior inline with go's
flaglibrary, 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():