-
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
Add flag category support #796
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.
Additionally I made some changes to the python generator scripts since python3 is becoming fairly common as the default python. The script currently blows up under python3 though. I also have some cleanup to do around methods I added that weren't actually needed after digging deeper into the code base. |
If you want to use this before it lands since review seems a bit slow on this project right now you can use the following which is an example from my go project. go1.11 required for it.
|
I was looking at adding global flag support for sub commands but it breaks a lot of unit tests so I'll move it into another PR. |
b0494d5
to
50b52ca
Compare
I'd split the |
Ah yeah, that just leaked in since I was using it locally for making testing it in my project easier. I'll clean that up. |
fc = fc.AddFlag(flag.GetCategory(), flag) | ||
} | ||
|
||
sort.Sort(fc) |
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.
Hello,
It is possible to add an option to be able to disable default sorting? I would like to sort categories by appearance :
...
OPTIONS:
scope
--scope1 value object_code
--scope2 value object test
mandatory
--john value JJ
--doe value DD
Flags: []cli.Flag{
cli.StringFlag{
Name: "scope1",
Category: "scope",
},
cli.StringFlag{
Name: "scope2",
Category: "scope",
},
cli.StringFlag{
Name: "john",
Category: "mandatory",
},
cli.StringFlag{
Name: "doe",
Category: "mandatory",
},
Thanks !
Heya! Looks like this PR has gotten fairly outdated. If you're still interested, can you rebase it? Also for the sake of readers, add a "Closes #259" to the top of the description? |
Closing pending user feedback! |
Any chance to get this reopened? |
Sorry I had a fork that I was using and am still using for my project that adds this and I didn't need any more work done. Feel free to take this though and open another PR. |
@michaeljs1990 Sorry for the very long delay 😭 I'm picking this up and attempting to get your changes incorporated into the current |
…support Add flag category support (#796)
Merged via #1368 |
This could be better and needs some cleanup as well as tests. It gives you the basic ability that I wanted which lets you set a category on a flag and have it printed in the help to break up commands with super long help messages. Global options ignore this right now but could be made to use it if someone messed with the template.
Here is an example output with this patch applied.
It also adds go mod support so I can overwrite the package locally with the mod replace syntax.