Mercurial > hgrepos > Python > apps > py-cutils
changeset 3:5a6ed622846c
Add comman line switches for reading in binary and text mode
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 04 Dec 2020 12:05:55 +0100 |
| parents | 5510a39a2d04 |
| children | 67d10529ce88 |
| files | shasum.py |
| diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/shasum.py Fri Dec 04 11:41:25 2020 +0100 +++ b/shasum.py Fri Dec 04 12:05:55 2020 +0100 @@ -23,17 +23,23 @@ def main(argv=None): - if argv is None: - argv = sys.argv[1:] - aparser = argparse.ArgumentParser( description="Python implementation of shasum", fromfile_prefix_chars='@') aparser.add_argument( + "--binary", "-b", action="store_false", dest="text_mode", default=False, + help="read in binary mode (default)") + aparser.add_argument( + "--text", "-t", action="store_true", dest="text_mode", default=False, + help="read in text mode (not yet supported)") + aparser.add_argument( "files", nargs="*", metavar="FILE") opts = aparser.parse_args(args=argv) + if opts.text_mode: + print("ERROR: text mode not supported", file=sys.stderr) + sys.exit(78) # :manpage:`sysexits(3)` EX_CONFIG if not opts.files: opts.files.append("-") for fn in opts.files:
