]> Sergey Matveev's repositories - meta4ra.git/commitdiff
meta4ra-hash -all
authorSergey Matveev <stargrave@stargrave.org>
Fri, 6 Mar 2026 07:25:05 +0000 (10:25 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 6 Mar 2026 07:25:05 +0000 (10:25 +0300)
cmd/hash.go
internal/common.go

index 579aea360fb4aeb79762d852ce6d4fcf721694fe..6550d513ec66195cb90621b982d650fe4701cc05 100644 (file)
@@ -30,6 +30,7 @@ import (
 func runHash() {
        hashes := flag.String("hashes", meta4ra.HashesDefault,
                "hash-name:commandline[,...]")
+       all := flag.Bool("all", false, "Print all hashes, not the first one")
        flag.Usage = func() {
                fmt.Fprintf(flag.CommandLine.Output(),
                        "Usage: %s [-hashes ...] <data | read hash name\n", os.Args[0])
@@ -50,8 +51,10 @@ Only the first hash from -hashes will be used.
        }
 
        hsh := *hashes
-       if i := strings.Index(hsh, ","); i != -1 {
-               hsh = hsh[:i]
+       if !*all {
+               if i := strings.Index(hsh, ","); i != -1 {
+                       hsh = hsh[:i]
+               }
        }
        hasher, err := meta4ra.NewHasher(hsh)
        if err != nil {
@@ -68,5 +71,11 @@ Only the first hash from -hashes will be used.
        if err != nil {
                log.Fatal(err)
        }
-       fmt.Println(sums[0].Hash, sums[0].Type)
+       if *all {
+               for _, h := range sums {
+                       fmt.Println(h.Type, h.Hash)
+               }
+       } else {
+               fmt.Println(sums[0].Hash, sums[0].Type)
+       }
 }
index dc6b781d39e994efca71a511eada5846385facd3..384f7a32091e018a4f9fc624ecc337abd629715a 100644 (file)
@@ -21,7 +21,7 @@ import (
 )
 
 const (
-       Generator       = "meta4ra/1.5.0"
+       Generator       = "meta4ra/1.6.0"
        SigMediaTypePGP = "application/pgp-signature"
        SigMediaTypeSSH = "application/ssh-signature"
        BufLen          = 1 << 20