"log"
"os"
"path"
+ "strings"
"time"
meta4ra "go.stargrave.org/meta4ra/internal"
)
func runCheck() {
+ plain := flag.Bool("plain", false,
+ ".meta4 is only a plain hashes list. That implies -pipe")
pipe := flag.Bool("pipe", false, "Verify file data from stdin, copy to stdout")
progress := flag.Bool("progress", false, "Show progress of piping/downloading")
allHashes := flag.Bool("all-hashes", false, "Check all hashes, not the first common one")
if err != nil {
log.Fatal(err)
}
- err = xml.Unmarshal(data, &meta)
- if err != nil {
- log.Fatal(err)
+ if *plain {
+ *pipe = true
+ meta.Files = []meta4ra.File{{Name: "-"}}
+ for line := range strings.SplitSeq(string(data), "\n") {
+ cols := strings.Split(line, " ")
+ if len(cols) != 2 {
+ continue
+ }
+ meta.Files[0].Hashes = append(meta.Files[0].Hashes,
+ meta4ra.Hash{Type: cols[0], Hash: cols[1]})
+ }
+ } else {
+ err = xml.Unmarshal(data, &meta)
+ if err != nil {
+ log.Fatal(err)
+ }
}
}
toCheck := make(map[string]string)
- for _, fn := range flag.Args()[1:] {
- toCheck[path.Base(fn)] = fn
- }
- if *pipe && len(toCheck) != 1 {
- log.Fatal("exactly single FILE must be specified when using -pipe")
+ if *plain {
+ toCheck["-"] = "-"
+ } else {
+ for _, fn := range flag.Args()[1:] {
+ toCheck[path.Base(fn)] = fn
+ }
+ if *pipe && len(toCheck) != 1 {
+ log.Fatal("exactly single FILE must be specified when using -pipe")
+ }
}
bad := false