summaryrefslogtreecommitdiff
path: root/source4/scripting/python/samba/netcmd/__init__.py
diff options
context:
space:
mode:
authorTheresa Halloran <thallora@linux.vnet.ibm.com>2011-11-02 10:33:12 -0400
committerAndrew Tridgell <tridge@samba.org>2011-11-07 01:39:24 +0100
commit384eaba38e4da2a2e72e1ec5bfea7d7776d16a11 (patch)
tree7262b175339e8968e11c1f6f012e8cb03328fad2 /source4/scripting/python/samba/netcmd/__init__.py
parentf0ae7e191682de1e56ca1ed2a9e9aa67e9d22b14 (diff)
downloadsamba-384eaba38e4da2a2e72e1ec5bfea7d7776d16a11.tar.gz
samba-384eaba38e4da2a2e72e1ec5bfea7d7776d16a11.tar.bz2
samba-384eaba38e4da2a2e72e1ec5bfea7d7776d16a11.zip
s4: samba-tool user --help documenation improvements
Signed-off-by: Theresa Halloran <thallora@linux.vnet.ibm.com> Autobuild-User: Andrew Tridgell <tridge@samba.org> Autobuild-Date: Mon Nov 7 01:39:25 CET 2011 on sn-devel-104
Diffstat (limited to 'source4/scripting/python/samba/netcmd/__init__.py')
-rw-r--r--source4/scripting/python/samba/netcmd/__init__.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py
index 58353a07f46..6d7ca43424e 100644
--- a/source4/scripting/python/samba/netcmd/__init__.py
+++ b/source4/scripting/python/samba/netcmd/__init__.py
@@ -25,10 +25,24 @@ from ldb import LdbError
import sys, traceback
import textwrap
-
class Option(optparse.Option):
pass
+# This help formatter does text wrapping and preserves newlines
+class PlainHelpFormatter(optparse.IndentedHelpFormatter):
+ def format_description(self,description=""):
+ desc_width = self.width - self.current_indent
+ indent = " "*self.current_indent
+ paragraphs = description.split('\n')
+ wrapped_paragraphs = [
+ textwrap.fill(p,
+ desc_width,
+ initial_indent=indent,
+ subsequent_indent=indent)
+ for p in paragraphs]
+ result = "\n".join(wrapped_paragraphs) + "\n"
+ return result
+
class Command(object):
"""A samba-tool command."""
@@ -108,6 +122,7 @@ class Command(object):
parser = optparse.OptionParser(
usage=self.synopsis,
description=self.full_description,
+ formatter=PlainHelpFormatter(),
prog=prog)
parser.add_options(self.takes_options)
optiongroups = {}