Overriden error method to throw exception instead of
printing usage error message. Exception is caught by
KickStart code to add .ks file name and line number.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
class KickStartError(Exception):
pass
+class KickStartParser(ArgumentParser):
+ """
+ This class overwrites error method to throw exception
+ instead of producing usage message(default argparse behavior).
+ """
+ def error(self, message):
+ raise ArgumentError(None, message)
+
def sizetype(arg):
"""
Custom type for ArgumentParser
self.bootloader = None
self.lineno = 0
- parser = ArgumentParser()
+ parser = KickStartParser()
subparsers = parser.add_subparsers()
part = subparsers.add_parser('part')