mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:19:01 +02:00

For scripts that use Python's standard argparse module to parse command-line arguments, create a subclass which will show the usage the usage information when a command-line parsing error occurs. The most common case would be when the script is run with no arguments; at least then the user immediately gets to see what arguments they might need to pass instead of just an error message. (From OE-Core rev: d62fe7c9bc2df6a4464440a3cae0539074bf99aa) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
12 lines
258 B
Python
12 lines
258 B
Python
import sys
|
|
import argparse
|
|
|
|
class ArgumentParser(argparse.ArgumentParser):
|
|
"""Our own version of argparse's ArgumentParser"""
|
|
|
|
def error(self, message):
|
|
sys.stderr.write('ERROR: %s\n' % message)
|
|
self.print_help()
|
|
sys.exit(2)
|
|
|