improve usage string failure mode on parse error
When using tab characters instead of spaces inside the usage string the resulting help message (or any output) is not the expected output.
Test case: In the following usage string from the default example replace the spaces between the options and their decription with tab. Do the same with any leading space:
static USAGE: &'static str = "
Usage: cp [-a] <source> <dest>
cp [-a] <source>... <dir>
Options:
-a, --archive Copy everything.
";
The result when running the resulting executable with no input:
Extraneous text ' Copy everything.' in option description '-a --archive Copy everything.'.
expected:
Invalid arguments.
Usage: cp [-a] <source> <dest>
cp [-a] <source>... <dir>
The error is a bit cryptic, but correct. From the Docopt spec:
Use two spaces to separate options with their informal description:
I don't have any opinions on whether tabs should be allowed or not, but you should propose this change to Docopt proper.
cc @keleshev
I have no problem with the spec. I simply did not understand that the output was indicating an error with the usage string. I thought it the result of some problems with the parser :(. Just a suggestion, but maybe you could add a prefix to the message indicating that it is a usage string parse error..
@dovreshef Ah, I misunderstood. I've re-opened and changed the title to be more specific. Thanks!
Use two spaces to separate options with their informal description:
It more looks like "at least two spaces".