diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-11-17 20:41:01 -0700 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-11-17 20:41:01 -0700 |
commit | 75d1918996dc62a99927d3f7e2ff13404c67ef5b (patch) | |
tree | 43590ea80456dabe47deefdbc2eec6fbf4468318 /ipalib/cli.py | |
parent | 8474bd01da13b9b72ba06e832d4c35ef6ccf5c9e (diff) | |
download | freeipa.git-75d1918996dc62a99927d3f7e2ff13404c67ef5b.tar.gz freeipa.git-75d1918996dc62a99927d3f7e2ff13404c67ef5b.tar.xz freeipa.git-75d1918996dc62a99927d3f7e2ff13404c67ef5b.zip |
Added some experimental textui methods
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r-- | ipalib/cli.py | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index 909e2acb..f1d8eebe 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -220,7 +220,7 @@ class textui(backend.Backend): value = repr(value) self.print_indented('%s: %s' % (key, value), indent) - def print_dashed(self, string, above=True, below=True): + def print_dashed(self, string, above=True, below=True, indent=0, dash='-'): """ Print a string with a dashed line above and/or below. @@ -238,12 +238,42 @@ class textui(backend.Backend): ------------------ Only dashed above. """ - dashes = '-' * len(string) + assert isinstance(dash, basestring) + assert len(dash) == 1 + dashes = dash * len(string) if above: - print dashes - print string + self.print_indented(dashes, indent) + self.print_indented(string, indent) if below: - print dashes + self.print_indented(dashes, indent) + + def print_h1(self, text): + """ + Print a primary header at indentation level 0. + + For example: + + >>> ui = textui() + >>> ui.print_h1('A primary header') + ================ + A primary header + ================ + """ + self.print_dashed(text, indent=0, dash='=') + + def print_h2(self, text): + """ + Print a secondary header at indentation level 1. + + For example: + + >>> ui = textui() + >>> ui.print_h2('A secondary header') + ------------------ + A secondary header + ------------------ + """ + self.print_dashed(text, indent=1, dash='-') def print_name(self, name): """ |