diff shasum.py @ 9:81f28bf89c26

Some more output selection options and documentation
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 04 Dec 2020 15:50:28 +0100
parents 048b97213a23
children 77446cd3ea6f
line wrap: on
line diff
--- a/shasum.py	Fri Dec 04 15:18:40 2020 +0100
+++ b/shasum.py	Fri Dec 04 15:50:28 2020 +0100
@@ -33,8 +33,14 @@
         "--binary", "-b", action="store_false", dest="text_mode", default=False,
         help="read in binary mode (default)")
     aparser.add_argument(
-        "--bsd", "-B", action="store_true",
-        help="write BSD style output")
+        "--bsd", "-B", action="store_true", dest="bsd", default=False,
+        help="write BSD style output; also :command:`openssl dgst` style")
+    aparser.add_argument(
+        "--reverse", "-r", action="store_false", dest="bsd", default=False,
+        help="explicitely select normal coreutils style output (to be option compatible with BSD style commands and :command:`openssl dgst -r`)")
+    aparser.add_argument(
+        "--tag", action="store_true", dest="bsd", default=False,
+        help="alias for the `--bsd' option (to be compatible with :command:`b2sum`)")
     aparser.add_argument(
         "--text", "-t", action="store_true", dest="text_mode", default=False,
         help="read in text mode (not supported)")
@@ -122,6 +128,10 @@
 
 
 def out_bsd(dest, digest, filename, digestname, binary):
+    """BSD format output, also :command:`openssl dgst` and
+    :command:`b2sum --tag" format output
+
+    """
     if filename is None:
         print(digest, file=dest)
     else:
@@ -130,6 +140,9 @@
 
 
 def out_std(dest, digest, filename, digestname, binary):
+    """Coreutils format (:command:`shasum` et al.)
+
+    """
     print("{} {}{}".format(digest,
                            '*' if binary else ' ',
                            '-' if filename is None else filename),