Summary
Two small correctness issues:
1. Root command accepts arbitrary arguments silently
main.go:13-16:
rootCmd := &cobra.Command{
Use: "gorm",
Short: "GORM CLI Tool",
}
Running gorm foo bar silently does nothing instead of reporting an error. Add:
Or cobra.MaximumNArgs(0) if that reads better.
2. version command uses fmt.Printf instead of cmd.Printf
main.go:31-39:
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("gorm-cli version %s\n", ...)
}
Using cmd.Println or cmd.Printf allows tests to capture output via cmd.OutOrStdout(). Also, the command uses Run instead of RunE — inconsistent with the gen command.
RunE: func(cmd *cobra.Command, args []string) error {
// ...
cmd.Printf("gorm-cli version %s\n", version)
return nil
},
Summary
Two small correctness issues:
1. Root command accepts arbitrary arguments silently
main.go:13-16:Running
gorm foo barsilently does nothing instead of reporting an error. Add:Or
cobra.MaximumNArgs(0)if that reads better.2.
versioncommand usesfmt.Printfinstead ofcmd.Printfmain.go:31-39:Using
cmd.Printlnorcmd.Printfallows tests to capture output viacmd.OutOrStdout(). Also, the command usesRuninstead ofRunE— inconsistent with thegencommand.