From: Gerhard Sittig Date: Sat, 19 Feb 2022 11:43:36 +0000 (+0100) Subject: sigrok-fwextract-kingst-la2016: use argparse(3) for commandline options X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=76358ac298251ac8bc9cefdf633e95cccbd1c40c;p=sigrok-util.git sigrok-fwextract-kingst-la2016: use argparse(3) for commandline options Neither open code the access to the sys.argv[] detail nor indices of positional arguments. Use the argparse(3) Python module instead, which transparently handles presence checks and provides a help text. --- diff --git a/firmware/kingst-la/sigrok-fwextract-kingst-la2016 b/firmware/kingst-la/sigrok-fwextract-kingst-la2016 index 4357994..1a2bfcb 100755 --- a/firmware/kingst-la/sigrok-fwextract-kingst-la2016 +++ b/firmware/kingst-la/sigrok-fwextract-kingst-la2016 @@ -18,6 +18,7 @@ ## along with this program; if not, see . ## +import argparse import os import sys import re @@ -187,11 +188,12 @@ def maybe_intel_hex_as_blob(data): return data # keep binary data if __name__ == "__main__": - if len(sys.argv) != 2: - print("sigrok-fwextract-kingst-la2016 ") - sys.exit() + parser = argparse.ArgumentParser(description = "KingstVIS firmware extraction") + parser.add_argument('executable', help = "KingstVIS executable file") + options = parser.parse_args() + exe_fn = options.executable - res = qt_resources(sys.argv[1]) + res = qt_resources(exe_fn) writer = res_writer(res)