calculate checksums
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
791 B

package main
import (
"flag"
"fmt"
"os"
"runtime"
)
var algo = flag.String("a", "sha256", "algorithm to use")
var mode = flag.Bool("c", false, "check")
var recursive = flag.Bool("r", false, "recursive")
var ngo = flag.Int("n", runtime.NumCPU(), "number of goroutines")
var verbose = flag.Bool("v", false, "vebose")
func main() {
flag.Parse()
files := flag.Args()
switch *mode {
case true:
ec := 0
for err := range check(files, *verbose) {
ec++
fmt.Fprintf(os.Stderr, "%v\n", err)
}
if ec > 0 {
os.Exit(1)
}
case false:
ec := 0
for res := range hsh(files, *verbose, *recursive) {
if res.err != nil {
ec++
fmt.Fprintf(os.Stderr, "%v\n", res.err)
} else {
fmt.Printf("%v %v\n", res.cs, res.f)
}
}
if ec > 0 {
os.Exit(1)
}
}
}