#
# (This license applies to this file but not necessarily the other files in
# this package.)
-#
+#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
-#
+#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
-#
+#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
-#
+#
# THIS SOFTWARE IS PROVIDED BY AVERY PENNARUN ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
Long option flags are used as the option's key for the OptDict produced when
parsing options.
-When the flag definition is ended with an equal sign, the option takes one
-string as an argument. Otherwise, the option does not take an argument and
-corresponds to a boolean flag that is true when the option is given on the
-command line.
+When the flag definition is ended with an equal sign, the option takes
+one string as an argument, and that string will be converted to an
+integer when possible. Otherwise, the option does not take an argument
+and corresponds to a boolean flag that is true when the option is
+given on the command line.
The option's description is found at the right of its flags definition, after
one or more spaces. The description ends at the end of the line. If the
"""Print usage string to stderr and abort."""
sys.stderr.write(self._usagestr)
if msg:
- sys.stderr.write(msg)
+ sys.stderr.write("\n" + msg)
e = self._onabort and self._onabort(msg) or None
if e:
raise e
def fatal(self, msg):
"""Print an error message to stderr and abort with usage string."""
- msg = '\nerror: %s\n' % msg
+ msg = 'Error: %s!' % msg
return self.usage(msg)
def parse(self, args):