Improved error messages and DocoptExit - #63
Conversation
|
Do you think that |
|
It's kind of tangential to docopt's purpose, but which just looks silly, and coming up with an error message for that case seemed saner than coding an exception. However, I'm not sure myself what the error message should say. Precise diagnostics on exactly where the invocation failed would be nice, but I haven't familiarized myself with |
|
@ghost : I’m not clear on your second explanation. I think what you’re saying is this: “When the user invokes the program with an invalid usage pattern, it’s more helpful to get an error that points to the invalid part(s), instead of just printing the entire Usage pattern.” Is that right? |
Error messages fixed pursuant of #43. There's also a new method,
docopt.exit(), that behaves exactly likesys.exit()when called withNoneor an integer argument, but prepends the argument with the program name and appends it with an usage message when called with anything else.DocoptExitwas changed to reflect this. (The program name is read from the docstring, notsys.argv[0].)I also changed the error message given on a failed usage pattern match to
missing operand(s), asmissing operandis what GNU programs say when you give them too few arguments. This probably still needs improvement, because a pattern mismatch can also happen in a few corner cases where there is technically no "missing operand", I think.