Mercurial > hg > lxmldump
changeset 72:0849d65fabce
More work on improving help.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 09 Dec 2021 10:31:50 +0200 |
parents | 8481f8f52a84 |
children | 4e27677ca5a9 |
files | lxmldump.py |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lxmldump.py Thu Dec 09 10:11:26 2021 +0200 +++ b/lxmldump.py Thu Dec 09 10:31:50 2021 +0200 @@ -487,7 +487,6 @@ print(u"\nAvailable output modes:") print(" " + ", ".join(pkk_modes_list.values())) - def error(self, message): self.print_help() sys.stderr.write(f"\nerror: {message}\n") @@ -500,7 +499,7 @@ ) optparser.add_argument("filenames", - type=str, action="extend", nargs="+", + type=str, action="extend", nargs="*", metavar="filename", help="XML filename(s)") @@ -555,16 +554,24 @@ pkk_cfg = optparser.parse_args() if pkk_cfg.list_values: + print(u"\nAvailable output modes:") + print(" " + ", ".join(pkk_modes_list.values())) + if pkk_cfg.mode not in [PKK_MODE_NORMAL, PKK_MODE_ANKI]: pkk_cfg.mode = PKK_MODE_NORMAL - print(u"Available format strings and values (mode '{}'):".format( + print(u"\nAvailable format strings and values (mode '{}'):".format( pkk_modes_list[pkk_cfg.mode])) for mid in pkk_mode_defaults: stmp = pkk_get_value(mid).replace("\\", "\\\\").replace("\n", "\\n") print(u" {:22s} : '{}'".format(mid, stmp)) + sys.exit(0) + + elif len(pkk_cfg.filenames) == 0: + optparser.print_help() + ### Handle each input file for filename in pkk_cfg.filenames: # Parse XML file into element tree