]> gitweb.michael.orlitzky.com - dead/census-tools.git/blobdiff - src/CLI.py
Modified the default_option_parser function to return a parser using a VerbatimHelpFo...
[dead/census-tools.git] / src / CLI.py
index eb8b21904a53ff622dcecf592f8a8dea481e4b81..93ac2a058ab1fb39998043e76b1a6ff64538f6ad 100644 (file)
@@ -1,11 +1,18 @@
+from optparse import IndentedHelpFormatter
 from optparse import OptionParser
 
 import Configuration.Defaults
 
 
-def default_option_parser(usage):
+def default_option_parser(usage=None):
+    # Use a VerbatimFormatter instead of the default
+    # IndentedHelpFormatter.    
+    fmtr = VerbatimHelpFormatter()
+    
     # -h (help) Conflicts with -h HOSTNAME
-    parser = OptionParser(usage=usage, add_help_option = False)
+    parser = OptionParser(usage = usage,
+                          add_help_option = False,
+                          formatter = fmtr)
 
     parser.add_option('-h',
                       '--host',
@@ -23,3 +30,15 @@ def default_option_parser(usage):
                       default=Configuration.Defaults.DATABASE_USERNAME)
 
     return parser
+
+
+
+class VerbatimHelpFormatter(IndentedHelpFormatter):
+    """
+    The two HelpFormatters supplied with OptParse like to mangle their
+    descriptions during print_help(). This subclassed formatter
+    overrides the format_description() method with an implementation
+    that simply returns the description unmodified.
+    """
+    def format_description(self, description):
+        return description