Patch from Rene Liebscher: this adds "--help-foo" options to list the
values that "--foo" can take for various commands: eg. what formats for
"sdist" and "bdist", what compilers for "build_ext" and "build_clib".

I have *not* reviewed this patch; I'm checking it in as-is because it also
fixes a paper-bag-over-head bug in bdist.py, and because I won't have
time to review it properly for several days: so someone else can
test it for me, instead!
diff --git a/Lib/distutils/command/bdist.py b/Lib/distutils/command/bdist.py
index 3cd1eb0..66ef113 100644
--- a/Lib/distutils/command/bdist.py
+++ b/Lib/distutils/command/bdist.py
@@ -21,8 +21,7 @@
     user_options = [('bdist-base=', 'b',
                      "temporary directory for creating built distributions"),
                     ('formats=', None,
-                     "formats for distribution " +
-                     "(gztar, bztar, zip, rpm, ... )"),
+                     "formats for distribution"),
                    ]
 
     # The following commands do not take a format option from bdist
@@ -33,12 +32,28 @@
     default_format = { 'posix': 'gztar',
                        'nt': 'zip', }
 
-    format_command = { 'gztar': 'bdist_dumb',
-                       'bztar': 'bdist_dumb',
-                       'ztar':  'bdist_dumb',
-                       'tar':   'bdist_dumb',
-                       'rpm':   'bdist_rpm',
-                       'zip':   'bdist_dumb', }
+    format_command = { 'gztar': ('bdist_dumb',"gzipped tar-file"),
+                       'bztar': ('bdist_dumb',"bzip2-ed tar-file"),
+                       'ztar':  ('bdist_dumb',"compressed tar-file"),
+                       'tar':   ('bdist_dumb',"tar-file"),
+                       'rpm':   ('bdist_rpm',"rpm distribution"),
+                       'zip':   ('bdist_dumb',"zip-file"),
+		        }
+
+    # prints all possible arguments to --format
+    def show_formats():
+	from distutils.fancy_getopt import FancyGetopt 
+	list_of_formats=[]
+	for format in bdist.format_command.keys():
+	    list_of_formats.append(("formats="+format,None,bdist.format_command[format][1]))
+	list_of_formats.sort()
+	pretty_printer=FancyGetopt(list_of_formats)
+	pretty_printer.print_help("List of available distribution formats:")
+
+    help_options = [
+        ('help-formats', None,
+         "lists available distribution formats",show_formats),
+	]
 
 
     def initialize_options (self):
@@ -74,14 +89,14 @@
         for format in self.formats:
 
             try:
-                cmd_name = self.format_command[self.format]
+                cmd_name = self.format_command[format][0]
             except KeyError:
                 raise DistutilsOptionError, \
-                      "invalid format '%s'" % self.format
+                      "invalid format '%s'" % format
 
             sub_cmd = self.reinitialize_command(cmd_name)
             if cmd_name not in self.no_format_option:
-                sub_cmd.format = self.format
+                sub_cmd.format = format
             self.run_command (cmd_name)
 
     # run()
diff --git a/Lib/distutils/command/build.py b/Lib/distutils/command/build.py
index b0894b8..c064f83 100644
--- a/Lib/distutils/command/build.py
+++ b/Lib/distutils/command/build.py
@@ -9,6 +9,7 @@
 import sys, os
 from distutils.core import Command
 from distutils.util import get_platform
+from distutils.ccompiler import show_compilers
 
 class build (Command):
 
@@ -35,6 +36,10 @@
         ('force', 'f',
          "forcibly build everything (ignore file timestamps)"),
         ]
+    help_options = [
+        ('help-compiler', None,
+         "lists available compilers",show_compilers),
+	]
 
     def initialize_options (self):
         self.build_base = 'build'
diff --git a/Lib/distutils/command/build_clib.py b/Lib/distutils/command/build_clib.py
index dba9a40..72df372 100644
--- a/Lib/distutils/command/build_clib.py
+++ b/Lib/distutils/command/build_clib.py
@@ -23,7 +23,7 @@
 from types import *
 from distutils.core import Command
 from distutils.errors import *
-from distutils.ccompiler import new_compiler
+from distutils.ccompiler import new_compiler,show_compilers
 
 
 class build_clib (Command):
@@ -42,6 +42,10 @@
         ('compiler=', 'c',
          "specify the compiler type"),
         ]
+    help_options = [
+        ('help-compiler', None,
+         "lists available compilers",show_compilers),
+	]
 
     def initialize_options (self):
         self.build_clib = None
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index f487a68..53a265c 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -14,6 +14,7 @@
 from distutils.errors import *
 from distutils.dep_util import newer_group
 from distutils.extension import Extension
+from distutils.ccompiler import show_compilers
 
 # An extension name is just a dot-separated list of Python NAMEs (ie.
 # the same as a fully-qualified module name).
@@ -72,6 +73,10 @@
         ('compiler=', 'c',
          "specify the compiler type"),
         ]
+    help_options = [
+        ('help-compiler', None,
+         "lists available compilers",show_compilers),
+	]
 
 
     def initialize_options (self):
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index af88eba..221a4d9 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -13,7 +13,7 @@
 from distutils.core import Command
 from distutils.util import newer, create_tree, remove_tree, convert_path, \
      write_file
-from distutils.archive_util import check_archive_formats
+from distutils.archive_util import check_archive_formats,ARCHIVE_FORMATS
 from distutils.text_file import TextFile
 from distutils.errors import DistutilsExecError, DistutilsOptionError
 
@@ -35,11 +35,26 @@
         ('force-manifest', 'f',
          "forcibly regenerate the manifest and carry on as usual"),
         ('formats=', None,
-         "formats for source distribution (tar, ztar, gztar, bztar, or zip)"),
+         "formats for source distribution"),
         ('keep-tree', 'k',
          "keep the distribution tree around after creating " +
          "archive file(s)"),
         ]
+    # prints all possible arguments to --formats
+    def show_formats():
+	from distutils.fancy_getopt import FancyGetopt 
+	list_of_formats=[]
+	for format in ARCHIVE_FORMATS.keys():
+	    list_of_formats.append(("formats="+format,None,ARCHIVE_FORMATS[format][2]))
+	list_of_formats.sort()
+	pretty_printer=FancyGetopt(list_of_formats)
+	pretty_printer.print_help("List of available distribution formats:")
+
+    help_options = [
+        ('help-formats', None,
+         "lists available distribution formats",show_formats),
+	]
+
     negative_opts = {'use-defaults': 'no-defaults'}
 
     default_format = { 'posix': 'gztar',