changeset 20:c8efa4369189

fixes to option parsing
author catherine@cordelia
date Thu, 15 May 2008 17:38:15 -0400
parents 1899088dd95d
children 82dde2f60e46 e72eb9137a87
files cmd2.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Thu May 15 13:44:48 2008 -0400
+++ b/cmd2.py	Thu May 15 17:38:15 2008 -0400
@@ -45,8 +45,11 @@
         optionParser.set_usage("%s [options] arg" % func.__name__.strip('do_'))
         def newFunc(instance, arg):
             try:
-                opts, arg = optionParser.parse_args(arg.split())  
-            except optparse.OptionValueError, e:
+                opts, arg = optionParser.parse_args(arg.split())
+                arg = ' '.join(arg)
+            except (optparse.OptionValueError, optparse.BadOptionError,
+                    optparse.OptionError, optparse.AmbiguousOptionError,
+                    optparse.OptionConflictError), e:
                 print e
                 optionParser.print_help()
                 return