changeset 31:4cbefe4c6f53

Improve help, list the default Ptr format strings for each mode.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 25 May 2021 12:40:35 +0300
parents 34755af2ea1f
children cfecd039506e
files lxmldump.py
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lxmldump.py	Tue May 25 12:40:03 2021 +0300
+++ b/lxmldump.py	Tue May 25 12:40:35 2021 +0300
@@ -250,7 +250,7 @@
 optparser = argparse.ArgumentParser(
     description="lxmldump - Dump ISO/FDIS 1951 XML file data",
     usage="%(prog)s [options] <input xml file(s)>",
-    epilog="\n\n"
+    add_help=False
     )
 
 optparser.add_argument("filenames",
@@ -258,6 +258,11 @@
     metavar="filename",
     help="XML filename(s)")
 
+optparser.add_argument("-h", "--help",
+    dest="show_help",
+    action="store_true",
+    help="show this help message and exit")
+
 optparser.add_argument("-d", "--dump",
     dest="mode",
     action="store_const", const=PKK_MODE_DUMP, default=PKK_MODE_NORMAL,
@@ -299,8 +304,14 @@
 
 ### Show help if needed
 pkk_cfg = optparser.parse_args()
-if len(pkk_cfg.filenames) == 0:
+if len(pkk_cfg.filenames) == 0 or pkk_cfg.show_help:
     optparser.print_help()
+
+    print(u"\nDefault Ptr format strings per mode:")
+    for pmode in pkk_modes_list:
+        if pmode in pkk_ptr_url_fmt:
+            print(u" {:6s} : \"{}\"".format(pkk_modes_list[pmode], pkk_ptr_url_fmt[pmode]))
+    print(u"")
     sys.exit(0)