# HG changeset patch # User Matti Hamalainen # Date 1621170644 -10800 # Node ID 76856fc4e5fa06ad05e90b06d4ef58124654f981 # Parent 7ef08e05a5bf333305336d74158d738ba137ad7b Clean up argument handling. diff -r 7ef08e05a5bf -r 76856fc4e5fa lxmldump.py --- a/lxmldump.py Tue May 11 18:37:53 2021 +0300 +++ b/lxmldump.py Sun May 16 16:10:44 2021 +0300 @@ -65,7 +65,7 @@ ## Print string with indentation def pkk_printi(indent, smsg): - pkk_print((" " * indent) + smsg) + pkk_print((" " * pkk_cfg.indent * indent) + smsg) ## Check value against current verbosity level @@ -218,33 +218,46 @@ epilog="\n\n" ) -optparser.add_argument("filenames", action="extend", nargs="*", - type=str, metavar="filename", help="XML filename(s)") +optparser.add_argument("filenames", + type=str, action="extend", nargs="*", + metavar="filename", + help="XML filename(s)") optparser.add_argument("-d", "--dump", + dest="mode", action="store_const", const=PKK_MODE_DUMP, default=PKK_MODE_NORMAL, - dest="mode", help="output as simple dump") + help="output as simple dump") optparser.add_argument("-x", "--xml", + dest="mode", action="store_const", const=PKK_MODE_XML, - dest="mode", help="output as XML") + help="output as XML") optparser.add_argument("-n", "--normalize", + dest="normalize", action="store_const", const=True, default=False, - dest="normalize", help="output NFC normalized Unicode") + help="output NFC normalized Unicode") optparser.add_argument("-a", "--annotate", + dest="annotate", action="store_const", const=True, default=False, - dest="annotate", help="annotate strings") + help="annotate strings") optparser.add_argument("-v", "--verbosity", - type=int, choices=range(0,4), default=3, + dest="verbosity", + type=int, choices=range(0, 4), default=3, metavar="n", - dest="verbosity", help='set verbosity level (0-3, default: %(default)s)') + help='set verbosity level (0-3, default: %(default)s)') optparser.add_argument("-p", "--debug", - action="store_const", const=True, default=False, - dest="debug", help=argparse.SUPPRESS) + dest="debug", action="store_const", const=True, default=False, + help=argparse.SUPPRESS) + +optparser.add_argument("-i", "--indent", + dest="indent", + type=int, choices=range(0, 32), default=4, + metavar="n", + help='indent output by characters (default: %(default)s)') ### Show help if needed