From 6ee47b9d0b267a95679bbcc19dbe8acdb25797de Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Thu, 20 May 2021 16:59:22 +0200 Subject: cdx: add -B best effort flag --- skate/cmd/skate-cdx-lookup/main.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/skate/cmd/skate-cdx-lookup/main.go b/skate/cmd/skate-cdx-lookup/main.go index b480078..308fffb 100644 --- a/skate/cmd/skate-cdx-lookup/main.go +++ b/skate/cmd/skate-cdx-lookup/main.go @@ -17,9 +17,10 @@ import ( ) var ( - sleep = flag.Duration("s", 200*time.Millisecond, "sleep between requests") - cacheDir = flag.String("c", path.Join(xdg.CacheHome, "skate-cdx"), "cache dir") - quiet = flag.Bool("q", false, "no logging") + sleep = flag.Duration("s", 200*time.Millisecond, "sleep between requests") + cacheDir = flag.String("c", path.Join(xdg.CacheHome, "skate-cdx"), "cache dir") + bestEffort = flag.Bool("B", false, "best effort") + quiet = flag.Bool("q", false, "no logging") ) func main() { @@ -54,7 +55,12 @@ func main() { if !cache.Has(line) { _, b, err := skate.LookupCDX(line) if err != nil { - log.Fatal(err) + if *bestEffort { + log.Println(err) + continue + } else { + log.Fatal(err) + } } if err := cache.Set(line, b); err != nil { log.Fatal(err) @@ -66,7 +72,10 @@ func main() { log.Fatal(err) } rows, err := skate.ParseCDX(b) - if err != nil { + if *bestEffort { + log.Println(err) + continue + } else { log.Fatal(err) } fmt.Printf("[%05d] % 10d %s %s\n", i, len(rows), rows.Summary(), line) -- cgit v1.2.3