[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Note --help convention



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.seul.org:/tmp/cvs-serv10393/lib/mixminion

Modified Files:
	Main.py 
Log Message:
Note --help convention

Index: Main.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Main.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Main.py	22 Nov 2002 21:01:49 -0000	1.9
+++ Main.py	2 Dec 2002 03:47:46 -0000	1.10
@@ -89,17 +89,22 @@
 	sys.exit(1)
 
 # Global map from command name to 2-tuples of (module_name, function_name).
-# 
-#   'Main.py <cmd> arg1 arg2 arg3' will result in a call to function_name
+#
+# DOCDOC unclear!
+#
+#  'Main.py <cmd> arg1 arg2 arg3' will result in a call to function_name
 #   in module_name.  The function should take two arguments: a string to
-#   be used as command name in error messages, and a list of [arg1,arg2,arg3].
+#   be used as command name in error messages, and a list of [arg1,arg2,arg3].'
+#   
+#   By convention, all commands must print a usage message and exit when
+#   invoked with a single argument, "--help"
 _COMMANDS = {
-    "version" : ( 'mixminion.Main', 'printVersion'),
-    "unittests" : ( 'mixminion.test', 'testAll' ),
-    "benchmarks" : ( 'mixminion.benchmark', 'timeAll' ),
-    "client" : ( 'mixminion.ClientMain', 'runClient' ),
-    "server" : ( 'mixminion.ServerMain', 'runServer' ),
-    "server-keygen" : ( 'mixminion.ServerMain', 'runKeygen'),
+    "version" :        ( 'mixminion.Main',       'printVersion'),
+    "unittests" :      ( 'mixminion.test',       'testAll' ),
+    "benchmarks" :     ( 'mixminion.benchmark',  'timeAll' ),
+    "client" :         ( 'mixminion.ClientMain', 'runClient' ),
+    "server" :         ( 'mixminion.ServerMain', 'runServer' ),
+    "server-keygen" :  ( 'mixminion.ServerMain', 'runKeygen'),
     "server-DELKEYS" : ( 'mixminion.ServerMain', 'removeKeys'),
 }
 
@@ -135,10 +140,11 @@
 
     # Invoke the command.
     try:
-        func(" ".join(args[0:2]), args[2:])
+        commandStr = " ".join(args[0:2])
+        func(commandStr, args[2:])
     except getopt.GetoptError, e:
-        print >>sys.stderr, e
-        func(" ".join(args[0:2]), ["--help"])
+        sys.stderr.write(str(e)+"\n")
+        func(commandStr, ["--help"])
 
 if __name__ == '__main__':
     main(sys.argv)