Clean up displaying help of global options, only one row per option.
authorThomas Arendsen Hein <thomas@intevation.de>
Fri, 26 Aug 2005 09:15:04 +0200
changeset 1051 3c918b7ad8da
parent 1050 9c09094de48c
child 1052 d8279ca39dc7
Clean up displaying help of global options, only one row per option.
mercurial/commands.py
--- a/mercurial/commands.py	Fri Aug 26 08:47:43 2005 +0200
+++ b/mercurial/commands.py	Fri Aug 26 09:15:04 2005 +0200
@@ -352,17 +352,15 @@
     # global options
     if ui.verbose:
         ui.write("\nglobal options:\n\n")
-        for s, l, d, c in globalopts:
-            opt = ' '
-            if s:
-                opt = opt + '-' + s + ' '
-            if l:
-                opt = opt + '--' + l + ' '
-            if d:
-                opt = opt + '(' + str(d) + ')'
-            ui.write(opt, "\n")
-            if c:
-                ui.write('    %s\n' % c)
+        opts, descriptions = [], []
+        for shortopt, longopt, default, desc in globalopts:
+            opts.append("%2s%s" %
+                        (shortopt and "-%s" % shortopt,
+                         longopt and " --%s" % longopt))
+            descriptions.append(desc)
+        opts_len = max(map(len, opts))
+        for opt, desc in zip(opts, descriptions):
+            ui.write(" %-*s  %s\n" % (opts_len, opt, desc))
 
 # Commands start here, listed alphabetically