From 314f03a5bbd7bac9b29902de0c220fa3f724732b Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Fri, 21 Feb 2014 13:49:35 -0500 Subject: [PATCH] api: Let generate_option_group prepend a prefix to added options (imported from commit 41cdd90a83914139c92cb3ea649cb5653f56d4ca) --- zulip/__init__.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/zulip/__init__.py b/zulip/__init__.py index c7cc2b0..137c1fb 100644 --- a/zulip/__init__.py +++ b/zulip/__init__.py @@ -48,25 +48,29 @@ API_VERSTRING = "v1/" def _default_client(): return "ZulipPython/" + __version__ -def generate_option_group(parser): +def generate_option_group(parser, prefix=''): group = optparse.OptionGroup(parser, 'Zulip API configuration') - group.add_option('--site', + group.add_option('--%ssite' % (prefix,), + dest="site", help="Zulip Enterprise server URI (if using Zulip Enterprise)", default=None) - group.add_option('--api-key', + group.add_option('--%sapi-key' % (prefix,), + dest="api_key", action='store') - group.add_option('--user', + group.add_option('--%suser' % (prefix,), dest='email', help='Email address of the calling bot or user.') - group.add_option('--config-file', + group.add_option('--%sconfig-file' % (prefix,), action='store', + dest="config_file", help='Location of an ini file containing the\nabove information. (default ~/.zuliprc)') group.add_option('-v', '--verbose', action='store_true', help='Provide detailed output.') - group.add_option('--client', + group.add_option('--%sclient' % (prefix,), action='store', default=None, + dest="client", help=optparse.SUPPRESS_HELP) return group