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

Proposed fix for GH-2 #16

Merged
merged 3 commits into from Apr 17, 2012
Merged

Proposed fix for GH-2 #16

merged 3 commits into from Apr 17, 2012

Conversation

oscarbenjamin
Copy link
Contributor

Hi,

This patch changes the way that globaloptions are merged into opts. The result is that options can use '-h' in the obvious way (see the test script) without disabling '--help'. This should fix GH-2.

The old behaviour was to refuse to include any global option if either its long or short name conflicted with another option. The result of this is that an option with short name '-h' would prevent the help option from being added to the command (I didn't get the stacktrace reported in GH-2).

With this patch the new behaviour is to refuse to include a global option if its long name matches any local option (since these are definitely not compatible). If the short name matches, then the short name is used for the local option. This means that if an option declares '-h', then '--help' will still be available but '-h' will refer to the new option.

In the general case when using dispatch this behaviour could lead to unexpected results where for example the short name for a global option would have a different meaning in some subcommands. However, if someone is overriding the short name of a global option in a local option I can't see what other behaviour they should expect.

Thanks,
Oscar.

@piranha
Copy link
Owner

piranha commented Apr 17, 2012

That looks nice, thank you very much.

piranha pushed a commit that referenced this pull request Apr 17, 2012
Proper handling of option '-h'.
@piranha piranha merged commit 4181d61 into piranha:master Apr 17, 2012
@oscarbenjamin
Copy link
Contributor Author

No worries.

Perhaps I should add something to the docs about this behaviour?

@piranha
Copy link
Owner

piranha commented Apr 17, 2012

I thought about that - if you have ideas where to mention that, it would be nice, but in the end this behavior seems to be quite natural... Hm... No, you are right, some clarification in documentation won't harm. If you have some time, I would love to see another patch from you. :)

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.

Declaring -h option results in a stack trace
2 participants