docopt.hs
docopt.hs copied to clipboard
Make usage-/help-string behavior consistent with original `docopt`
Fixes https://github.com/docopt/docopt.hs/issues/32.
This makes 3 main changes to this library's behavior:
-
pUsagePatterns(and thuspDocopt) 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. -
exitWithUsageandexitWithUsaegMessagenow print that "short usage string" rather than the whole helpstring.exitWithHelpstringhas been added, which prints the whole helpstring. -
parseArgsOrExitautomatically exits printing the helpstring iflongOption "help"is present, to be more consistent with the originaldocoptbehavior. I'm not sure this is the correct place in the library to put it, but it creates the intended behavior.