[Pkg-bazaar-commits] ./bzr/unstable r332: - nicer formatting of help for options

Martin Pool mbp at sourcefrog.net
Fri Apr 10 07:43:45 UTC 2009


------------------------------------------------------------
revno: 332
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Tue 2005-05-03 17:56:14 +1000
message:
  - nicer formatting of help for options
modified:
  bzrlib/commands.py
-------------- next part --------------
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2005-05-03 07:48:16 +0000
+++ b/bzrlib/commands.py	2005-05-03 07:56:14 +0000
@@ -741,11 +741,22 @@
     if rest:
         print rest
 
-    if cmdclass.takes_options:
-        print
-        print 'options:'
-        for on in cmdclass.takes_options:
-            print '    --%s' % on
+    help_on_option(cmdclass.takes_options)
+
+
+def help_on_option(options):
+    if not options:
+        return
+    
+    print
+    print 'options:'
+    for on in options:
+        l = '    --' + on
+        for shortname, longname in SHORT_OPTIONS.items():
+            if longname == on:
+                l += ', -' + shortname
+                break
+        print l
 
 
 def help_commands():
@@ -764,7 +775,7 @@
         help = inspect.getdoc(cmdclass)
         if help:
             print "    " + help.split('\n', 1)[0]
-
+            
 
 ######################################################################
 # main routine



More information about the Pkg-bazaar-commits mailing list