File tree Expand file tree Collapse file tree 3 files changed +74
-1
lines changed
Expand file tree Collapse file tree 3 files changed +74
-1
lines changed Original file line number Diff line number Diff line change 11hashsum-about = Compute and check message digests.
22hashsum-usage = hashsum --<digest> [OPTIONS]... [FILE]...
33
4+ # Utility-specific usage strings
5+ hashsum-usage-md5sum = md5sum [OPTION]... [FILE]...
6+ hashsum-usage-sha1sum = sha1sum [OPTION]... [FILE]...
7+ hashsum-usage-sha224sum = sha224sum [OPTION]... [FILE]...
8+ hashsum-usage-sha256sum = sha256sum [OPTION]... [FILE]...
9+ hashsum-usage-sha384sum = sha384sum [OPTION]... [FILE]...
10+ hashsum-usage-sha512sum = sha512sum [OPTION]... [FILE]...
11+ hashsum-usage-b2sum = b2sum [OPTION]... [FILE]...
12+ hashsum-usage-b3sum = b3sum [OPTION]... [FILE]...
13+ hashsum-usage-sha3sum = sha3sum [OPTION]... [FILE]...
14+ hashsum-usage-sha3-224sum = sha3-224sum [OPTION]... [FILE]...
15+ hashsum-usage-sha3-256sum = sha3-256sum [OPTION]... [FILE]...
16+ hashsum-usage-sha3-384sum = sha3-384sum [OPTION]... [FILE]...
17+ hashsum-usage-sha3-512sum = sha3-512sum [OPTION]... [FILE]...
18+ hashsum-usage-shake128sum = shake128sum [OPTION]... [FILE]...
19+ hashsum-usage-shake256sum = shake256sum [OPTION]... [FILE]...
20+
421# Help messages
522hashsum-help-binary-windows = read or check in binary mode (default)
623hashsum-help-binary-other = read in binary mode
Original file line number Diff line number Diff line change @@ -498,7 +498,7 @@ pub fn uu_app_custom() -> Command {
498498/// hashsum is handled differently in build.rs
499499/// therefore, this is different from other utilities.
500500fn uu_app ( binary_name : & str ) -> ( Command , bool ) {
501- match binary_name {
501+ let ( mut command , is_hashsum_bin ) = match binary_name {
502502 // These all support the same options.
503503 "md5sum" | "sha1sum" | "sha224sum" | "sha256sum" | "sha384sum" | "sha512sum" => {
504504 ( uu_app_common ( ) , false )
@@ -516,7 +516,18 @@ fn uu_app(binary_name: &str) -> (Command, bool) {
516516 "b3sum" => ( uu_app_b3sum ( ) , false ) ,
517517 // We're probably just being called as `hashsum`, so give them everything.
518518 _ => ( uu_app_custom ( ) , true ) ,
519+ } ;
520+
521+ // If not called as generic hashsum, override the command name and usage
522+ if !is_hashsum_bin {
523+ let usage_key = format ! ( "hashsum-usage-{}" , binary_name) ;
524+ let usage = translate ! ( & usage_key) ;
525+ command = command
526+ . help_template ( uucore:: localized_help_template ( binary_name) )
527+ . override_usage ( format_usage ( & usage) ) ;
519528 }
529+
530+ ( command, is_hashsum_bin)
520531}
521532
522533#[ allow( clippy:: cognitive_complexity) ]
Original file line number Diff line number Diff line change @@ -1080,3 +1080,48 @@ fn test_check_sha256_binary() {
10801080 . no_stderr ( )
10811081 . stdout_is ( "binary.png: OK\n " ) ;
10821082}
1083+
1084+ #[ test]
1085+ fn test_help_shows_correct_utility_name ( ) {
1086+ // Test that help output shows the actual utility name instead of "hashsum"
1087+ let scene = TestScenario :: new ( util_name ! ( ) ) ;
1088+
1089+ // Test md5sum
1090+ scene
1091+ . ccmd ( "md5sum" )
1092+ . arg ( "--help" )
1093+ . succeeds ( )
1094+ . stdout_contains ( "Usage: md5sum" )
1095+ . stdout_does_not_contain ( "Usage: hashsum" ) ;
1096+
1097+ // Test sha256sum
1098+ scene
1099+ . ccmd ( "sha256sum" )
1100+ . arg ( "--help" )
1101+ . succeeds ( )
1102+ . stdout_contains ( "Usage: sha256sum" )
1103+ . stdout_does_not_contain ( "Usage: hashsum" ) ;
1104+
1105+ // Test b2sum
1106+ scene
1107+ . ccmd ( "b2sum" )
1108+ . arg ( "--help" )
1109+ . succeeds ( )
1110+ . stdout_contains ( "Usage: b2sum" )
1111+ . stdout_does_not_contain ( "Usage: hashsum" ) ;
1112+
1113+ // Test b3sum
1114+ scene
1115+ . ccmd ( "b3sum" )
1116+ . arg ( "--help" )
1117+ . succeeds ( )
1118+ . stdout_contains ( "Usage: b3sum" )
1119+ . stdout_does_not_contain ( "Usage: hashsum" ) ;
1120+
1121+ // Test that generic hashsum still shows the correct usage
1122+ scene
1123+ . ccmd ( "hashsum" )
1124+ . arg ( "--help" )
1125+ . succeeds ( )
1126+ . stdout_contains ( "Usage: hashsum --<digest>" ) ;
1127+ }
You can’t perform that action at this time.
0 commit comments