groundcover-com / murre

Murre is an on-demand, scaleable source of container resource metrics for K8s.
https://www.groundcover.com/blog/murre
Apache License 2.0
310 stars 18 forks source link

Show errors on pgm startup #24

Open giuliohome opened 1 year ago

giuliohome commented 1 year ago

Describe the bug Show the errors and not the command help if the arguments are missing or correct and the runtime throws.

To Reproduce Steps to reproduce the behavior:

  1. Stop your minikube (or whatever k8s you use)
  2. Start murre
  3. See the command help instead of the actual error

Expected behavior The actual exception should be reported to the output: showing the command arguments help is misleading when there is no usage error in the command line itself!

giuliohome commented 1 year ago

At first sight, I'd guess the bug is here,

func Execute() error {
    return RootCmd.Execute()
}

and the correct way to do that is explained here:

if err := myCommand.Execute(); err != nil {
        // There was an error! Print the error message and exit. Or do whatever you'd like!
        // This includes errors like "invalid argument" etc.
    fmt.Println(err)
    os.Exit(1)
}