Feature: Add support for persistent flags#1568
Merged
dearchap merged 2 commits intourfave:mainfrom Nov 27, 2022
Merged
Conversation
Contributor
|
And what happens if local flags conflict with global? |
Contributor
Author
|
Local wins over global |
Contributor
|
With no warning during compilation? |
Contributor
Author
|
This cant be detected during compile time. At runtime the local flags are applied to flagset first and then we walk higher up the chain . Only those flags marked as persistent up the chain will be applied to current flagset only if none of their names/aliases conflict with local . It is up to the user to make sure that the conflicts dont happen. |
meatballhat
requested changes
Nov 6, 2022
Member
meatballhat
left a comment
There was a problem hiding this comment.
This is very exciting! Thank you for doing this work 🎉
Contributor
|
@dearchap just to clarify. If be equal to this ? |
Contributor
Author
|
@abitrolly Yes correct. |
joeycumines
reviewed
Nov 6, 2022
meatballhat
reviewed
Nov 7, 2022
2d8e012 to
0711cb0
Compare
d9bd2de to
fc7b194
Compare
3 tasks
8 tasks
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.
What type of PR is this?
(REQUIRED)
What this PR does / why we need it:
(REQUIRED)
Long asked for feature to have flags in flexible order
Which issue(s) this PR fixes:
(REQUIRED)
Fixes #427
Fixes #1113
Special notes for your reviewer:
(fill-in or delete this section)
Testing
(fill-in or delete this section)
go test -run=TestPersistentFlag
Release Notes
(REQUIRED)
Flags can be marked as persistent in which case they can appear in subcommands. Flags with the same name in subcommand take precedence over commands defined higher in the hierarchy. Since a flag can have multiple names/aliases it is upto the user to ensure that none of the aliases of persistent flags are defined in subcommands. Even if one of the names is matched in a subcommand none of the aliases are applied to subcommand flag parsing