[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools - app.py:1.13

Fred L. Drake, Jr. fred at zope.com
Thu Apr 1 19:54:47 EST 2004


Update of /cvs-repository/Packages/zpkgtools/zpkgtools
In directory cvs.zope.org:/tmp/cvs-serv869/zpkgtools

Modified Files:
	app.py 
Log Message:
change the signature of the command line helper function a little, so optparse
will have the right command name for error messages


=== Packages/zpkgtools/zpkgtools/app.py 1.12 => 1.13 ===
--- Packages/zpkgtools/zpkgtools/app.py:1.12	Thu Apr  1 17:36:42 2004
+++ Packages/zpkgtools/zpkgtools/app.py	Thu Apr  1 19:54:16 2004
@@ -295,8 +295,17 @@
 """
 
 
-def parse_args(args):
+def parse_args(argv):
+    """Parse the command line, return an options object and the
+    positional arguments.
+
+    :Parameters:
+      - `argv`: The command line arguments, including argv[0].
+
+    """
+
     parser = optparse.OptionParser(
+        prog=os.path.basename(argv[0]),
         usage="usage: %prog [options] resource",
         version="%prog 0.1")
     parser.add_option(
@@ -328,13 +337,17 @@
         "-v", dest="version",
         help="version label for the new distribution",
         default="0.0.0")
-    return parser.parse_args(args)
+    return parser.parse_args(argv[1:])
 
 
 def main(argv=None):
     if argv is None:
         argv = sys.argv
-    options, args = parse_args(argv[1:])
+    try:
+        options, args = parse_args(argv)
+    except SystemExit, e:
+        print >>sys.stderr, e
+        return 2
 
     # figure out what to read from:
     if len(args) != 1:




More information about the Zope-CVS mailing list