Browse Source

a little more information for incorrect arguments

David Rose 14 years ago
parent
commit
16ae6aa182
1 changed files with 9 additions and 5 deletions
  1. 9 5
      direct/src/p3d/pdeploy.py

+ 9 - 5
direct/src/p3d/pdeploy.py

@@ -133,7 +133,8 @@ from direct.p3d.DeploymentTools import Standalone, Installer
 from pandac.PandaModules import Filename, PandaSystem
 from pandac.PandaModules import Filename, PandaSystem
 
 
 def usage(code, msg = ''):
 def usage(code, msg = ''):
-    print >> sys.stderr, usageText % {'prog' : os.path.split(sys.argv[0])[1]}
+    if not msg:
+        print >> sys.stderr, usageText % {'prog' : os.path.split(sys.argv[0])[1]}
     print >> sys.stderr, msg
     print >> sys.stderr, msg
     sys.exit(code)
     sys.exit(code)
 
 
@@ -154,7 +155,7 @@ includeRequires = False
 try:
 try:
     opts, args = getopt.getopt(sys.argv[1:], 'n:N:v:o:t:P:csl:L:a:A:e:h')
     opts, args = getopt.getopt(sys.argv[1:], 'n:N:v:o:t:P:csl:L:a:A:e:h')
 except getopt.error, msg:
 except getopt.error, msg:
-    usage(1, msg)
+    usage(1, msg or 'Invalid option')
 
 
 for opt, arg in opts:
 for opt, arg in opts:
     if opt == '-n':
     if opt == '-n':
@@ -188,11 +189,14 @@ for opt, arg in opts:
     elif opt == '-h':
     elif opt == '-h':
         usage(0)
         usage(0)
     else:
     else:
-        print 'illegal option: ' + flag
-        sys.exit(1)
+        msg = 'illegal option: ' + flag
+        print msg
+        sys.exit(1, msg)
 
 
 if not args or len(args) != 2:
 if not args or len(args) != 2:
-    usage(1)
+    msg = 'Wrong number of arguments, received %s, expected 2' % (
+        len(args or []))
+    usage(1, msg)
 
 
 appFilename = Filename.fromOsSpecific(args[0])
 appFilename = Filename.fromOsSpecific(args[0])
 if appFilename.getExtension().lower() != 'p3d':
 if appFilename.getExtension().lower() != 'p3d':