Refactored the command listing
authorAaron Bentley <aaron.bentley@utoronto.ca>
Sat, 1 Apr 2006 19:55:34 +0000 (14:55 -0500)
committerAaron Bentley <aaron.bentley@utoronto.ca>
Sat, 1 Apr 2006 19:55:34 +0000 (14:55 -0500)
be
becommands/help.py
libbe/cmdutil.py

diff --git a/be b/be
index f4225bd46ef08f187be6ebb864c755b1e01f46f8..8ad6a9815abd2c30987345a76aa94237f3ed3b60 100755 (executable)
--- a/be
+++ b/be
@@ -48,14 +48,7 @@ Unimplemented becommands
 
 
 if len(sys.argv) == 1 or sys.argv[1] in ('--help', '-h'):
-    cmdlist = []
-    print """Bugs Everywhere - Distributed bug tracking
-    
-Supported commands"""
-    for name, module in cmdutil.iter_commands():
-        cmdlist.append((name, module.__doc__))
-    for name, desc in cmdlist:
-        print "be %s\n    %s" % (name, desc)
+    print_command_list()
 else:
     try:
         try:
index fc8920759d88e570af7c9bce86073c45d9ca6250..cae8949de2482030e15c191d2e3d4014fa8c0e3f 100644 (file)
@@ -24,8 +24,7 @@ def execute(args):
     if len(args) > 1:
         raise cmdutil.UserError("Too many arguments.")
     if len(args) == 0:
-        for name, module in cmdutil.iter_commands():
-            print "be %s\n     %s" % (name, module.__doc__)
+        print_command_list()
     else:
         print cmdutil.help(args[0])
     return
index 2f24490cdf5ee1a347a8d1c31a58d065ad990764..b2c7f8a6e1298de96c82751ad5449b0b36de45b8 100644 (file)
@@ -167,6 +167,15 @@ def bug_tree(dir=None):
     except bugdir.NoBugDir, e:
         raise UserErrorWrap(e)
 
+def print_command_list():
+    cmdlist = []
+    print """Bugs Everywhere - Distributed bug tracking
+    
+Supported commands"""
+    for name, module in iter_commands():
+        cmdlist.append((name, module.__doc__))
+    for name, desc in cmdlist:
+        print "be %s\n    %s" % (name, desc)
 
 def _test():
     import doctest