refactor: add sabliercmd pkg#727
Conversation
This will enable doc generation
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the codebase by extracting CLI command implementation from the cmd/sablier directory into a new pkg/sabliercmd package. This enables documentation generation for the CLI commands and improves code organization.
Key changes:
- Command implementations moved from
cmd/sablier,cmd/version, andcmd/healthcheckintopkg/sabliercmdpackage - Package-level variables and functions reorganized to support testability with new testing utilities
- Fixed grammar issues in help text ("start containers" instead of "start container", "provides integrations" instead of "provides an integrations")
Reviewed Changes
Copilot reviewed 10 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/sabliercmd/version.go | Moved from cmd/version, renamed package and function (NewCmd → NewVersionCmd) |
| pkg/sabliercmd/theme.go | Moved from cmd/sablier, renamed package, reorganized imports |
| pkg/sabliercmd/testing.go | New testing utilities to enable mocking and config manipulation in tests |
| pkg/sabliercmd/testdata/* | New test data files (JSON, YAML, and env configs) for configuration testing |
| pkg/sabliercmd/start.go | Moved from cmd/sablier, renamed package, refactored start command creation |
| pkg/sabliercmd/root.go | New file containing root command logic moved from cmd/sablier/cmd.go |
| pkg/sabliercmd/provider.go | Moved from cmd/sablier, renamed package, reorganized imports |
| pkg/sabliercmd/logger.go | Moved from cmd/sablier, renamed package, reorganized imports |
| pkg/sabliercmd/healthcheck.go | Moved from cmd/healthcheck, renamed package and function (NewCmd → NewHealthCmd) |
| pkg/sabliercmd/cmd_test.go | Updated tests to use new package structure with testing utilities |
| cmd/sablier/cmd.go | Simplified to only call NewRootCommand from sabliercmd package |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // ResetStartCommand resets the start command to the default | ||
| func ResetStartCommand() { | ||
| newStartCommand = NewStartCommand | ||
| } |
There was a problem hiding this comment.
The ResetStartCommand function creates a circular reference. It assigns newStartCommand = NewStartCommand, but NewStartCommand is just an exported alias for newStartCommand (line 9). This means resetting will not work as intended - it will just set newStartCommand to its current value instead of restoring it to the original function.
The function should store the original function in a separate variable and reset to that, or use a different approach. For example:
var defaultStartCommand = newStartCommand
func ResetStartCommand() {
newStartCommand = defaultStartCommand
}| _ = viper.BindPFlag("provider.auto-stop-on-startup", startCmd.Flags().Lookup("provider.auto-stop-on-startup")) | ||
| startCmd.Flags().Float32Var(&conf.Provider.Kubernetes.QPS, "provider.kubernetes.qps", 5, "QPS limit for K8S API access client-side throttling") | ||
| _ = viper.BindPFlag("provider.kubernetes.qps", startCmd.Flags().Lookup("provider.kubernetes.qps")) | ||
| startCmd.Flags().IntVar(&conf.Provider.Kubernetes.Burst, "provider.kubernetes.burst", 10, "Maximum burst for K8S API acees client-side throttling") |
There was a problem hiding this comment.
Spelling error: "acees" should be "access".
| startCmd.Flags().IntVar(&conf.Provider.Kubernetes.Burst, "provider.kubernetes.burst", 10, "Maximum burst for K8S API acees client-side throttling") | |
| startCmd.Flags().IntVar(&conf.Provider.Kubernetes.Burst, "provider.kubernetes.burst", 10, "Maximum burst for K8S API access client-side throttling") |
| func NewRootCommand() *cobra.Command { | ||
| rootCmd := &cobra.Command{ | ||
| Use: "sablier", | ||
| Short: "A webserver to start container on demand", |
There was a problem hiding this comment.
Grammar issue: "to start container" should be "to start containers" (plural) to match the Long description which says "starts containers".
| Short: "A webserver to start container on demand", | |
| Short: "A webserver to start containers on demand", |
|
✅ All tests successful. No failed tests were found. 📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
|
@acouvreur I've opened a new pull request, #728, to work on those changes. Once the pull request is ready, I'll request review from you. |
|


This will enable doc generation