add argparse exception for banner

pull/1015/head
dev2ero 4 years ago committed by Disconnect3d
parent 9dac5d2371
commit e9b9ebe364

@ -133,12 +133,14 @@ parser.description = "Sets the output of a context section."
parser.add_argument("section", type=str, help="The section which is to be configured. ('regs', 'disasm', 'code', 'stack', 'backtrace', and/or 'args')")
parser.add_argument("path", type=str, help="The path to which the output is written")
parser.add_argument("clearing", type=bool, help="Indicates weather to clear the output")
parser.add_argument("banner", type=str, nargs='?', default="both", help="Where a banner should be placed: both, top , bottom, none")
banner_arg = parser.add_argument("banner", type=str, nargs='?', default="both", help="Where a banner should be placed: both, top , bottom, none")
parser.add_argument("width", type=int, nargs='?', default=None, help="Sets a fixed width (used for banner). Set to None for auto")
@pwndbg.commands.ArgparsedCommand(parser, aliases=['ctx-out'])
def contextoutput(section, path, clearing, banner="both", width=None):
if banner not in ('both', 'top', 'bottom', 'none'):
raise argparse.ArgumentError(banner_arg, f"banner can not be '{banner}'")
if width is not None:
width = int(width.cast(gdb.lookup_type('long')))
width = int(width)
outputs[section] = path
output_settings[section] = dict(clearing=clearing,
width=width,

Loading…
Cancel
Save