qapi: Fix generators to report command line errors decently

Report to stderr, prefix with the program name. Also reject
extra arguments.

Backports commit b45409683e829770000a4560ed21e704f87df74c from qemu
This commit is contained in:
Markus Armbruster 2018-02-19 15:20:05 -05:00 committed by Lioncash
parent 9415f6e863
commit dd67bbeb3b
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -988,7 +988,7 @@ def parse_command_line(extra_options = "", extra_long_options = []):
"input-file=", "output-dir="]
+ extra_long_options)
except getopt.GetoptError, err:
print str(err)
print >>sys.stderr, "%s: %s" % (sys.argv[0], str(err))
sys.exit(1)
output_dir = ""
@ -1016,4 +1016,8 @@ def parse_command_line(extra_options = "", extra_long_options = []):
do_c = True
do_h = True
if len(args) != 0:
print >>sys.stderr, "%s: too many arguments" % sys.argv[0]
sys.exit(1)
return (input_file, output_dir, do_c, do_h, prefix, extra_opts)