-
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
Add flag category support (#796) #1368
Conversation
This adds what I think needs to be done to support categories for flags but we will see if that works. It also forces the scripts to use python2 since they blow up under python3 which is becoming the default python on many linux systems. Small fix to app_test as well so it conforms to the new Flag interface.
Let us use this repo via replace locally.
…s1990/cli into michaeljs1990-add-flag-category-support
with internal maps instead of slices and slightly less public API surface area
type CategorizableFlag interface { | ||
VisibleFlag | ||
|
||
GetCategory() string |
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.
Rename to just Category(). golang doesnt recommend using GetXXX
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 about the conflict with the field name Category
? 🤔 I agree that GetXXX
is generally bad style, but this is a language-level wart we're working around.
catNames = append(catNames, name) | ||
} | ||
|
||
sort.Strings(catNames) |
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.
isnt f.m already sorted ?
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.
IIUC ranging over a map
has undefined sort order: https://go.dev/play/p/aR7JKg4ae8r Or did you mean something else? 🤔
flag_bool.go
Outdated
@@ -19,6 +19,7 @@ type BoolFlag struct { | |||
DefaultText string | |||
Destination *bool | |||
HasBeenSet bool | |||
Category string |
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.
@meatballhat How would this tie-in with your generator code ?
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.
If all the flag types defined in this repo have Category
fields, then it'd be part of the struct template. Or did you mean the potential merge conflict? (or something else?)
…g-category-support
…g-category-support
What type of PR is this?
What this PR does / why we need it:
See #796
Which issue(s) this PR fixes:
Closes #259
Special notes for your reviewer:
This PR is a best-effort porting of #796 so detailed criticism is very much appreciated 🙇🏼
Release Notes