@@ -1165,6 +1165,36 @@ def cmd_hash(self, args: argparse.Namespace, stdout: TextIO) -> bool:
11651165 print (f"MD5:\t { md5 } \n SHA1:\t { sha1 } \n SHA256:\t { sha256 } " , file = stdout )
11661166 return False
11671167
1168+ @arg ("path" )
1169+ def cmd_md5sum (self , args : argparse .Namespace , stdout : TextIO ) -> bool :
1170+ """print the MD5 checksum of a file provided by a path"""
1171+ if not (path := self .check_file (args .path )):
1172+ return False
1173+
1174+ (md5 ,) = path .get ().hash (["md5" ])
1175+ print (f"{ md5 } { path !s} " , file = stdout )
1176+ return False
1177+
1178+ @arg ("path" )
1179+ def cmd_sha1sum (self , args : argparse .Namespace , stdout : TextIO ) -> bool :
1180+ """print the SHA1 checksum of a file provided by a path"""
1181+ if not (path := self .check_file (args .path )):
1182+ return False
1183+
1184+ (sha1 ,) = path .get ().hash (["sha1" ])
1185+ print (f"{ sha1 } { path !s} " , file = stdout )
1186+ return False
1187+
1188+ @arg ("path" )
1189+ def cmd_sha256sum (self , args : argparse .Namespace , stdout : TextIO ) -> bool :
1190+ """print the SHA256 checksum of a file provided by a path"""
1191+ if not (path := self .check_file (args .path )):
1192+ return False
1193+
1194+ (sha256 ,) = path .get ().hash (["sha256" ])
1195+ print (f"{ sha256 } { path !s} " , file = stdout )
1196+ return False
1197+
11681198 @arg ("path" )
11691199 @alias ("head" )
11701200 @alias ("more" )
@@ -1482,7 +1512,6 @@ def build_pipe(pipe_parts: list[str], pipe_stdout: int = subprocess.PIPE) -> Ite
14821512 On context exit the generator will close the input stream and wait for
14831513 the subprocessess to finish.
14841514 """
1485-
14861515 if not pipe_parts :
14871516 raise ValueError ("No pipe components provided" )
14881517
0 commit comments