-
Notifications
You must be signed in to change notification settings - Fork 49
Migrate CLI entrypoint to main.go and Kong #549
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
Conversation
Moved the main CLI entry point from `cmd/bk/main.go` to `./main.go` and switched to Kong for command parsing. ## What's changed? - CLI entry point is now at the repository root - Using Kong parser with delegation to existing Cobra commands - All existing functionality works exactly the same - Moved `generate.go` to `cmd/generate/` to avoid conflicts ## Migration path Later we can implement native Kong commands in separate files and remove the delegation layer. But for now this gets us the Kong foundation without changing any behavior. I've added comments to the sections we can rip out once we're ready to move on. I've created this with the assumption that we will continue to create the subcommands within their respective files. Tested that all commands and help work the same as before.
mcncl
left a comment
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 looks awesome, @JoeColeman95. I wonder should we use kong.UsageOnError() so that the help is outputted when only bk or go run . is used? Thoughts?
scadu
left a comment
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.
I like the hybrid approach, so we can keep existing functionality intact!
Left a few comments around error handling and help page.
Hey @mcncl, yeah I agree – the functionality isn't quite as expected there though 🙁, see this issue: alecthomas/kong#33 I've implemented the workaround stated there so we still get the expected behavior, I've delegated both Essentially, I've implemented exactly what you've suggested but added a condition to |
Adding `kong.UsageOnError()` and also catching any runs of the cli without any options to ensure help is displayed as shown as a workaround in this issue: alecthomas/kong#33
Moved the main CLI entry point from
cmd/bk/main.goto./main.goand switched to Kong for command parsing.What's changed?
generate.gotocmd/generate/to avoid conflictsMigration path
Later we can implement native Kong commands in separate files and remove the delegation layer. But for now this gets us the Kong foundation without changing any behavior. I've added comments to the sections we can rip out once we're ready to move on. I've created this with the assumption that we will continue to create the subcommands within their respective files.
Tested that all commands and help work the same as before.