Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make usage-/help-string behavior consistent with original docopt #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jpdoyle
Copy link

@jpdoyle jpdoyle commented Feb 24, 2024

Fixes #32.

(moved from #50 -- it looks like it'll need a few more edits now since 2.5 years ago :) )

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.

Fixes docopt#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.
@DigitalBrains1
Copy link
Collaborator

Ah, thank you for opening a new PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prints whole usage string on incorrect arguments
2 participants