From 3e70c3b56b29dcc9c0f6dd15eee7d4a24945944a Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 24 Sep 2008 04:44:52 +0000 Subject: 325: API.finalize() now creates instance attribtue 'plugins', which is a tuple of PluginInfo objects; renamed show_plugins cli command to namespaces; added new cli command plugins --- ipalib/cli.py | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'ipalib/cli.py') diff --git a/ipalib/cli.py b/ipalib/cli.py index a76c08bc..7912f1b1 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -77,8 +77,8 @@ class console(frontend.Application): ) -class show_plugins(frontend.Application): - 'Print details on the loaded plugins.' +class namespaces(frontend.Application): + 'Show details of plugable namespaces' def run(self): lines = self.__traverse() @@ -112,6 +112,33 @@ class show_plugins(frontend.Application): self.__traverse_namespace(n, attr, lines, tab + 2) +class plugins(frontend.Application): + """Show all loaded plugins""" + + def run(self): + print '%s:\n' % self.name + for p in sorted(self.api.plugins, key=lambda o: o.plugin): + print ' plugin: %s' % p.plugin + print ' in namespaces: %s' % ', '.join(p.bases) + print '' + if len(self.api.plugins) == 1: + print '1 plugin loaded.' + else: + print '%d plugins loaded.' % len(self.api.plugins) + + + + + +cli_application_commands = ( + help, + console, + namespaces, + plugins, + +) + + class KWCollector(object): def __init__(self): object.__setattr__(self, '_KWCollector__d', {}) @@ -168,9 +195,8 @@ class CLI(object): def finalize(self): api = self.api - api.register(help) - api.register(console) - api.register(show_plugins) + for klass in cli_application_commands: + api.register(klass) api.finalize() for a in api.Application(): a.set_application(self) -- cgit