Add argparse to pripnglsch
from __future__ import print_function
+import argparse
import binascii
import sys
@@ -21,15 +22,11 @@ def list_chunks(out, inp):
def main(argv=None):
- if argv is None:
- argv = sys.argv
- arg = argv[1:]
-
- if len(arg) > 0:
- f = open(arg[0], "rb")
- else:
- f = png.binary_stdin()
- return list_chunks(sys.stdout, f)
+ parser = argparse.ArgumentParser()
+ parser.add_argument("png", nargs="?", default="-")
+ args = parser.parse_args()
+ inp = png.cli_open(args.png)
+ return list_chunks(sys.stdout, inp)
if __name__ == "__main__":
