[pypy-svn] r38926 - in pypy/dist/pypy: config tool

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Feb 15 17:52:50 CET 2007


Author: cfbolz
Date: Thu Feb 15 17:52:49 2007
New Revision: 38926

Modified:
   pypy/dist/pypy/config/config.py
   pypy/dist/pypy/tool/option.py
Log:
print the link with py.py too


Modified: pypy/dist/pypy/config/config.py
==============================================================================
--- pypy/dist/pypy/config/config.py	(original)
+++ pypy/dist/pypy/config/config.py	Thu Feb 15 17:52:49 2007
@@ -402,7 +402,8 @@
         return paths
 
 
-class OptHelpFormatter(optparse.IndentedHelpFormatter):
+class OptHelpFormatter(optparse.TitledHelpFormatter):
+    extra_useage = None
 
     def expand_default(self, option):
         assert self.parser
@@ -446,6 +447,14 @@
 
         return option.help
 
+    def format_usage(self, usage):
+        # XXX bit of a hack
+        result = optparse.TitledHelpFormatter.format_usage(self, usage)
+        if self.extra_useage is not None:
+            return result + "\n" + self.extra_useage + "\n\n"
+        return result
+
+
 
 class ConfigUpdate(object):
 
@@ -492,7 +501,7 @@
 
 
 def to_optparse(config, useoptions=None, parser=None,
-                parserargs=None, parserkwargs=None):
+                parserargs=None, parserkwargs=None, extra_useage=None):
     grps = {}
     def get_group(name, doc):
         steps = name.split('.')
@@ -509,8 +518,10 @@
             parserargs = []
         if parserkwargs is None:
             parserkwargs = {}
+        formatter = OptHelpFormatter()
+        formatter.extra_useage = extra_useage
         parser = optparse.OptionParser(
-            formatter=OptHelpFormatter(),
+            formatter=formatter,
             *parserargs, **parserkwargs)
     if useoptions is None:
         useoptions = config.getpaths(include_groups=True)

Modified: pypy/dist/pypy/tool/option.py
==============================================================================
--- pypy/dist/pypy/tool/option.py	(original)
+++ pypy/dist/pypy/tool/option.py	Thu Feb 15 17:52:49 2007
@@ -5,13 +5,17 @@
 from pypy.config.config import Config, OptionDescription, to_optparse
 from py.compat import optparse
 
+extra_useage = """For detailed descriptions of all the options see
+http://codespeak.net/pypy/dist/pypy/doc/config/commandline.html"""
+
 def run_tb_server(option, opt, value, parser):
     from pypy.tool import tb_server
     tb_server.start()
 
 def get_standard_options():
     config = get_pypy_config()
-    parser = to_optparse(config, useoptions=["objspace.*"])
+    parser = to_optparse(config, useoptions=["objspace.*"],
+                         extra_useage=extra_useage)
     parser.add_option(
         '-H', action="callback",
         callback=run_tb_server,



More information about the Pypy-commit mailing list