You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is definitely a mismatch of behavior from what the original docopt intended. On incorrect arguments it should print only the usage section without the options section. The options section should only be included as an output if someone types --help in the example link.
jpdoyle
added a commit
to jpdoyle/docopt.hs
that referenced
this issue
Sep 27, 2021
Fixesdocopt#32.
This makes 3 main changes to this library's behavior:
1) `pUsagePatterns` (and thus `pDocopt`) parses out the "Usage:" section
of the helpstring as a string and returns that. The way I'm parsing
it feels really hacky but I wasn't sure a better way to achieve it.
2) `exitWithUsage` and `exitWithUsaegMessage` now print that "short
usage string" rather than the whole helpstring. `exitWithHelpstring`
has been added, which prints the whole helpstring.
3) `parseArgsOrExit` automatically exits printing the helpstring if
`longOption "help"` is present, to be more consistent with the
original `docopt` behavior. I'm not sure this is the correct place in
the library to put it, but it creates the intended behavior.
Consider this example.
Per the reference implementation, an incorrect sequence of arguments should output the brief usage description. I adapted the example from the readme:
However, when I execute it with no arguments I get:
instead of the expected:
The text was updated successfully, but these errors were encountered: