dreamhost/cliff — pull request #19 by Kami (2012-09-11 06:23:09+00:00)
Title: Allow user to specify extra ArgumentParser kwargs

This branch allows user to pass `argparse_kwargs` kwarg to the `build_option_parser` method. This argument gets unpack and passed to the `ArgumentParser` constructor.

Example use case:

In my application I want to replace handler for the `--help` option without copy and pasting the code. I can achieve this by passing `conflict_handler='resolve'` kwarg to the `ArgumentParser` constructor.

For example:

```python
...
def build_option_parser(self, description, version):
parser = super(MyApp, self).build_option_parser(description,
version,
argparse_kwargs={'conflict_handler': 'resolve'})
print parser.conflict_handler
parser.add_argument(
'-h', '--help',
action=MyHelpAction,
nargs=0,
default=self,
help="show this help message and exit",
)
return parser
...
```