-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Feature: Add support for persistent flags #1568
Conversation
And what happens if local flags conflict with global? |
Local wins over global |
With no warning during compilation? |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very exciting! Thank you for doing this work 🎉
@dearchap just to clarify. If
be equal to this
? |
@abitrolly Yes correct. |
2d8e012
to
0711cb0
Compare
d9bd2de
to
fc7b194
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉🍕🎷🐻
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