]> code.ossystems Code Review - openembedded-core.git/commitdiff
scripts/lib/argparse_oe: show self.prog in the error message
authorChristopher Larson <chris_larson@mentor.com>
Wed, 27 Apr 2016 23:23:58 +0000 (16:23 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 6 May 2016 09:30:56 +0000 (10:30 +0100)
This aligns our subclassed error() with that in the original class, using
_print_message and self.prog. Also add a docstring based on the original.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/argparse_oe.py

index bf3ebaddfd9b244acfa319c1bcf8e8896ff34704..95b42e75ead06bd64c02018f7e32a4a1d9dffc98 100644 (file)
@@ -16,8 +16,13 @@ class ArgumentParser(argparse.ArgumentParser):
         super(ArgumentParser, self).__init__(*args, **kwargs)
 
     def error(self, message):
-        sys.stderr.write('ERROR: %s\n' % message)
-        self.print_help()
+        """error(message: string)
+
+        Prints a help message incorporating the message to stderr and
+        exits.
+        """
+        self._print_message('%s: error: %s\n' % (self.prog, message), sys.stderr)
+        self.print_help(sys.stderr)
         sys.exit(2)
 
     def error_subcommand(self, message, subcommand):