Permalink
Browse files

Fix handling bad number of arguments, so that help works.

  • Loading branch information...
1 parent c41b627 commit 8b5694ba65141ad9919d645263c36b82596b9a7c @cournape committed Dec 1, 2008
Showing with 8 additions and 4 deletions.
  1. +8 −4 xml2cython.py
View
12 xml2cython.py
@@ -59,10 +59,6 @@ def main(argv=None):
opts, args = getopt.getopt(argv[1:], "ho:l:f:",
["help", "output", "location-filter",
"function-name-filter"])
- if len(args) != 2:
- raise Usage("Error, exactly one input file must be specified")
- header_input = args[0]
- xml_input = args[1]
except getopt.error, msg:
raise Usage(msg)
except Usage, e:
@@ -85,6 +81,14 @@ def main(argv=None):
elif o in ("-f", "--function-name-filter"):
ffilter_str = a
+ if len(args) != 2:
+ print >>sys.stderr, "Error, exactly one input file must be specified"
+ print >>sys.stderr, "for help use --help"
+ return 2
+
+ header_input = args[0]
+ xml_input = args[1]
+
if lfilter_str:
lfilter = re.compile(lfilter_str).search

0 comments on commit 8b5694b

Please sign in to comment.