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

[minion-cvs] Improve usage and error messages



Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv14596/lib/mixminion/server

Modified Files:
	ServerMain.py 
Log Message:
Improve usage and error messages

Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerMain.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- ServerMain.py	5 Jan 2003 13:19:54 -0000	1.18
+++ ServerMain.py	6 Jan 2003 03:29:46 -0000	1.19
@@ -405,9 +405,17 @@
     sys.stdout = LogStream("STDOUT", "WARN")
     sys.stderr = LogStream("STDERR", "WARN")
 
+_SERVER_USAGE = """\
+Usage: %s [options]
+Options:
+  -h, --help:                Print this usage message and exit.
+  -f <file>, --config=<file> Use a configuration file other than
+                                /etc/mixminiond.conf
+""".strip()
+
 def usageAndExit(cmd):
     executable = sys.argv[0]
-    print >>sys.stderr, "Usage: %s %s [-h] [-f configfile]" % (executable, cmd)
+    print >>sys.stderr, _SERVER_USAGE %cmd
     sys.exit(0)
 
 def configFromServerArgs(cmd, args):
@@ -472,6 +480,15 @@
     sys.exit(0)
 
 #----------------------------------------------------------------------
+_KEYGEN_USAGE = """\
+Usage: %s [options]
+Options:
+  -h, --help:                Print this usage message and exit.
+  -f <file>, --config=<file> Use a configuration file other than
+                                /etc/mixminiond.conf
+  -n <n>, --keys=<n>         Generate <n> new keys. (Defaults to 1.)
+""".strip()
+
 def runKeygen(cmd, args):
     options, args = getopt.getopt(args, "hf:n:",
                                   ["help", "config=", "keys="])
@@ -493,7 +510,7 @@
                 print >>sys.stderr,("%s requires an integer" %opt)
                 usage = 1
     if usage:
-        print >>sys.stderr, "Usage: %s [-h] [-f configfile] [-n nKeys]"%cmd
+        print >>sys.stderr, _KEYGEN_USAGE % cmd
         sys.exit(1)
 
     config = readConfigFile(configFile)
@@ -507,6 +524,15 @@
         print >> sys.stderr, ".... (%s/%s done)" % (i+1,keys)
 
 #----------------------------------------------------------------------
+_REMOVEKEYS_USAGE = """\
+Usage: %s [options]
+Options:
+  -h, --help:                Print this usage message and exit.
+  -f <file>, --config=<file> Use a configuration file other than
+                                /etc/mixminiond.conf
+  --remove-identity          Remove the identity key as well.  (DANGEROUS!)
+""".strip()
+
 def removeKeys(cmd, args):
     # FFFF Resist removing keys that have been published.
     # FFFF Generate 'suicide note' for removing identity key.
@@ -527,9 +553,8 @@
         elif opt == '--remove-identity':
             removeIdentity = 1
     if usage:
-        print >>sys.stderr, \
-              "Usage: %s [-h|--help] [-f configfile] [--remove-identity]"%cmd
-        sys.exit(1)
+        print >>sys.stderr, _REMOVEKEYS_USAGE % cmd
+        sys.exit(0)
 
     config = readConfigFile(configFile)
     mixminion.Common.configureShredCommand(config)