]> sigrok.org Git - sigrok-util.git/commitdiff
sigrok-fwextract-kingst-la2016: use argparse(3) for commandline options
authorGerhard Sittig <redacted>
Sat, 19 Feb 2022 11:43:36 +0000 (12:43 +0100)
committerGerhard Sittig <redacted>
Sat, 19 Feb 2022 12:09:16 +0000 (13:09 +0100)
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.

firmware/kingst-la/sigrok-fwextract-kingst-la2016

index 4357994207762fadb837fbcf5d9d92ff8dc5f9cb..1a2bfcb49e02eb17689cd3f34495ac7b2cc64354 100755 (executable)
@@ -18,6 +18,7 @@
 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
 ##
 
+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 <programfile>")
-        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)