[CalendarServer-changes] [8430] CalendarServer/trunk/calendarserver/tools/shell.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Dec 12 17:16:37 PST 2011


Revision: 8430
          http://trac.macosforge.org/projects/calendarserver/changeset/8430
Author:   wsanchez at apple.com
Date:     2011-12-12 17:16:36 -0800 (Mon, 12 Dec 2011)
Log Message:
-----------
Improve format of help

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/shell.py

Modified: CalendarServer/trunk/calendarserver/tools/shell.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell.py	2011-12-12 22:33:20 UTC (rev 8429)
+++ CalendarServer/trunk/calendarserver/tools/shell.py	2011-12-13 01:16:36 UTC (rev 8430)
@@ -322,6 +322,7 @@
             self.terminal.write("Available commands:\n")
 
             result = []
+            max_len = 0
 
             for attr in dir(self):
                 if attr.startswith("cmd_"):
@@ -338,10 +339,17 @@
                     else:
                         doc = "(no info available)"
 
-                    result.append((attr[4:], doc))
+                    name = attr[4:]
 
+                    if len(name) > max_len:
+                        max_len = len(name)
+
+                    result.append((name, doc))
+
+            format = "  %%%ds - %%s\n" % (max_len,)
+
             for info in sorted(result):
-                self.terminal.write("  %s - %s\n" % (info))
+                self.terminal.write(format % (info))
 
     def cmd_emulate(self, tokens):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111212/fe30db98/attachment.html>


More information about the calendarserver-changes mailing list