summaryrefslogtreecommitdiffstats
path: root/ipalib/plugable.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2012-12-13 09:23:32 -0500
committerRob Crittenden <rcritten@redhat.com>2013-02-18 13:07:17 -0500
commit614082e6a6ba025583ce24a2cce94133997925d7 (patch)
tree17ec614b27923f35d66945b854e45bebbd11a358 /ipalib/plugable.py
parentabe26d55c8f43e3a213fe831df7f0536d0600288 (diff)
downloadfreeipa-614082e6a6ba025583ce24a2cce94133997925d7.tar.gz
freeipa-614082e6a6ba025583ce24a2cce94133997925d7.tar.xz
freeipa-614082e6a6ba025583ce24a2cce94133997925d7.zip
Add tests for the help command & --help options
Move the parser setup from bootstrap_with_global_options to bootstrap, so all API objects have access to it. Add some CLI tests for the help system. Part of the effort for https://fedorahosted.org/freeipa/ticket/3060
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r--ipalib/plugable.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 8f42c6304..fe09d3a6b 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -456,7 +456,7 @@ class API(DictProxy):
def isdone(self, name):
return name in self.__done
- def bootstrap(self, **overrides):
+ def bootstrap(self, parser=None, **overrides):
"""
Initialize environment variables and logging.
"""
@@ -516,6 +516,10 @@ class API(DictProxy):
log.error('Cannot open log file %r: %s', self.env.log, e)
return
+ if not parser:
+ parser = self.build_global_parser()
+ object.__setattr__(self, 'parser', parser)
+
def build_global_parser(self, parser=None, context=None):
"""
Add global options to an optparse.OptionParser instance.
@@ -592,8 +596,7 @@ class API(DictProxy):
overrides['webui_prod'] = options.prod
if context is not None:
overrides['context'] = context
- self.bootstrap(**overrides)
- object.__setattr__(self, 'parser', parser)
+ self.bootstrap(parser, **overrides)
return (options, args)
def load_plugins(self):