piranha/opster — pull request #16 by oscarbenjamin (2012-04-14 21:33:01+00:00)
Title: Proposed fix for GH-1

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-1.

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-1).

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.