-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
cmd: Expand cobra support, add short flags #5379
Conversation
8753b2a
to
7bafa9d
Compare
7bafa9d
to
e1f8531
Compare
Co-authored-by: Emily Lange <[email protected]>
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.
Thanks for this change!
Overall I like it. I wish we didn't have to hack in the Cobra API like that, but oh well.
I made many suggestions regarding short flags. I lean toward what you suggested: let's start with fewer short flags, until we determine where additional ones would be useful. I suggested removing them on the less-common flags, or ones where there was a difficult conflict and where I could see multiple different letters being good options, or where a clear choice wasn't obvious.
Hope that's OK. Let me know what you think!
Co-authored-by: Matt Holt <[email protected]>
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.
Thanks for working on this!
We've had Cobra in for a few versions now, and it's worked pretty well. Now, it's time to make it possible to use more of its features.
For that, I'm adding a new CobraFunc field to
caddycmd.Command
which allows configuring the command using the full power of Cobra's APIs while keeping backwards compatibility and ergonomics of ourRegisterCommand
setup.In addition, I ported every built-in command to use this new API (making sure commands still worked after the first commit), and added shorthands for most flags. Some of them are a bit funky due to the english language only having so many letters in the alphabet, but I think it should be reasonable. Let me know if you find any of them too weird. We could also just play it safe and enable less shorthands to start, not to paint ourselves into a corner with exhausting letters ahead of time 😂