riverqueue / river

Fast and reliable background jobs in Go
https://riverqueue.com
Mozilla Public License 2.0
3.22k stars 86 forks source link

Exit with status 1 on Cobra problems like a missing required flag #363

Closed brandur closed 3 months ago

brandur commented 3 months ago

Here, exit with status 1 from the River CLI when a problem intrinsic to Cobra occurred like the user entered an unknown command, or didn't pass required flag.

Cobra is a little odd in its behavior in that it already prints such a problem to the terminal, but also returns an error with the same information. This change looks for the presence of an error and exits with status 1 if one occurred, but doesn't double print any additional information about it.

Fixes #362.

brandur commented 3 months ago

Thanks!