summaryrefslogtreecommitdiffstats
path: root/ipalib/cli.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-04-03 10:40:30 +0200
committerMartin Kosek <mkosek@redhat.com>2013-04-03 15:32:03 +0200
commit4a30bf55ac3a067c668058299cbd355ab63e9dd9 (patch)
tree2eeb956f423e280904be94eebf5c20ef5f0e5cda /ipalib/cli.py
parentf770556946091ffaf2e17a0c3b20868d26f1a75e (diff)
downloadfreeipa-4a30bf55ac3a067c668058299cbd355ab63e9dd9.tar.gz
freeipa-4a30bf55ac3a067c668058299cbd355ab63e9dd9.tar.xz
freeipa-4a30bf55ac3a067c668058299cbd355ab63e9dd9.zip
Display full command documentation in online help
ipa <command> -h only showed the summary string, not the full help. Use the full docstring. Add a custom help formatter that disables optparse's reformatting. Test included https://fedorahosted.org/freeipa/ticket/3543
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r--ipalib/cli.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index d5a5b8429..84dea2e52 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -1098,7 +1098,8 @@ class cli(backend.Executioner):
def build_parser(self, cmd):
parser = CLIOptionParser(
usage=' '.join(self.usage_iter(cmd)),
- description=cmd.summary,
+ description=unicode(cmd.doc),
+ formatter=IPAHelpFormatter(),
)
option_groups = {}
for option in cmd.options():
@@ -1257,6 +1258,21 @@ class cli(backend.Executioner):
kw[p.name] = self.Backend.textui.decode(raw)
+class IPAHelpFormatter(optparse.IndentedHelpFormatter):
+ """Formatter suitable for printing IPA command help
+
+ The default help formatter reflows text to fit the terminal, but it
+ ignores line/paragraph breaks.
+ IPA's descriptions already have correct line breaks. This formatter
+ doesn't touch them (save for removing initial/trailing whitespace).
+ """
+ def format_description(self, description):
+ if description:
+ return description.strip()
+ else:
+ return ""
+
+
cli_plugins = (
cli,
textui,