INNER CODE UNIT · Python
parser
dhondta/python-codext · src/codext/__init__.py:112
parser = argparse.ArgumentParser(description=descr, epilog=examples, **kw)
sparsers = parser.add_subparsers(dest="command", help="command to be executed", required=True)
parser.add_argument("-i", "--input-file", dest="infile", help="input file (if none, take stdin as input)")
parser.add_argument("-o", "--output-file", dest="outfile", help="output file (if none, display result to stdout)")
parser.add_argument("-s", "--strip-newlines", action="store_true", dest="strip",
help="strip newlines from input (default: False)")
encode = sparsers.add_parser("encode", help="encode input using the specified codecs", **kw)
encode.add_argument("encoding", nargs="+", help="list of encodings to apply")
encode.add_argument("-e", "--errors", default="strict", choices=["ignore", "leave", "replace", "strict"],
help="error handling (default: strict)")
decode = sparsers.add_parser("decode", help="decode input using the specified codecs", **kw)
decode.add_argument("encoding", nargs="+", help="list of encodings to apply")
decode.add_argument("-e", "--errors", default="strict", choices=["ignore", "leave", "replace", "strict"],
help="error handling (default: strict)")
guess = sparsers.add_parser("guess", help="try guessing the decoding codecs", **kw)
guess.add_argument("encoding", nargs="*", help="list of known encodings to apply (default: none)")
guess.add_argument("-e", "--exclude", nargs="*", action="extend", metavar="CAT|COD|ENC",
help="categories, codecs and encodings to be explicitely not used ;\n "