cli icon indicating copy to clipboard operation
cli copied to clipboard

Improve error message when required argument is not set

Open apricote opened this issue 1 year ago • 0 comments

TL;DR

If a user does not pass a required (positional) argument, we return the generic error message hcloud: accepts 1 arg(s), received 0. This does not help the user in figuring out what the argument should be.

Expected behavior

I would prefer to see something along the lines of

hcloud: No $RESOURCE name was specified, please add the argument. To learn more, add the flag --help.

Right now we use the default cobra argument validators (mostly cobra.ExactArgs(1)) which produce this less-than-useful errors. We will need to write our own version of these validators with improved messages and maybe open an issue upstream to get better versions in cobra.

apricote avatar Feb 19 '24 06:02 apricote