show better error message when a validator fails #744
Labels
A-validators
Area: ArgMatches validation logi
C-enhancement
Category: Raise on the bar on expectations
Let's say a valid command line invocation is this:
but a user types this instead:
I have a validator function on the
j
flag that checks whether it's a valid number or not. If not, it returns an error so that the output looks like this:This is fine as far as it goes, but let's take a look at the output of an error when I try to use a value that clap knows is wrong for a different flag:
This error message is a lot better. In particular, the really critical piece of information is the name of the flag that's causing the problem. For example, consider a more complex command line:
There are a lot more numbers here, so it's harder to match up the error message with the actual CLI usage.
I think clap knows the flag name when a validator function fails. Could it include that in the error message?
(This is easily my favorite benefit of clap btw. Its failure modes are oh so much better than Docopt. Of course, I knew that before, but still, it's nice. :-))
The text was updated successfully, but these errors were encountered: