diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-24 05:03:10 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-24 05:03:10 +0000 |
commit | f3ac709922c33425c211b79787f1dedc03bb6508 (patch) | |
tree | 629bab4c117d62486ac79738f4ab89b5d147ae1e | |
parent | 3e70c3b56b29dcc9c0f6dd15eee7d4a24945944a (diff) | |
download | freeipa-f3ac709922c33425c211b79787f1dedc03bb6508.tar.gz freeipa-f3ac709922c33425c211b79787f1dedc03bb6508.tar.xz freeipa-f3ac709922c33425c211b79787f1dedc03bb6508.zip |
326: Made output of plugins cli command nicer
-rw-r--r-- | ipalib/cli.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index 7912f1b1..36a5bd1b 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -52,6 +52,23 @@ def from_cli(cli_name): return str(cli_name).replace('-', '_') +class text_ui(frontend.Application): + """ + Base class for CLI commands with special output needs. + """ + + def print_dashed(self, string, top=True, bottom=True): + dashes = '-' * len(string) + if top: + print dashes + print string + if bottom: + print dashes + + def print_name(self, **kw): + self.print_dashed('%s:' % self.name, **kw) + + class help(frontend.Application): 'Display help on a command.' @@ -112,19 +129,24 @@ class namespaces(frontend.Application): self.__traverse_namespace(n, attr, lines, tab + 2) -class plugins(frontend.Application): +class plugins(text_ui): """Show all loaded plugins""" def run(self): - print '%s:\n' % self.name + self.print_name() + first = True for p in sorted(self.api.plugins, key=lambda o: o.plugin): + if first: + first = False + else: + print '' print ' plugin: %s' % p.plugin print ' in namespaces: %s' % ', '.join(p.bases) - print '' if len(self.api.plugins) == 1: - print '1 plugin loaded.' + s = '1 plugin loaded.' else: - print '%d plugins loaded.' % len(self.api.plugins) + s = '%d plugins loaded.' % len(self.api.plugins) + self.print_dashed(s) |