Remove Cobra dependency #51
Open
GLobyNew wants to merge 3 commits into
Open
Conversation
Owner
|
Thanks for digging into this. The register pattern looks really clean! One thing worth flagging on the size numbers: the ~4 MB reduction is from a plain
So the real-world saving is closer to ~2.9 MB (still a legit reduction) I'm not sure the tradeoff is worth it right now. Cobra is widely used, maintained, supported, and we get its help generation, per-command help, and consistent flag handling. Replacing it means hand-maintaining more CLI behavior ourselves. I don't want to discourage the refactoring, but I'm going to hold off on merging it for now. Thank you for putting it together! |
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.
This one is controversial and I won't be sad if you won't merge it.
I was into this code for last week and I have an itch on refactoring.
I tried to remove
spf13/cobraand it came a bit messy.I believe it's less convenient, but nevertheless, I've added a cli.go - which is basically stripped cobra for only quien's needs.
Then I re-register all commands using register function and restore same logic that was with Cobra.
The result is binary size for the most part and one less direct and two less indirect dependencies.
Size of binary of main branch right now (18138 kB):
After removing Cobra (13960 kB):
Net size: -4178 kB
Once again, its only up to you if this added complexity is worth 4MB of binary size.