aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-05-20 16:59:22 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-05-20 16:59:22 +0200
commit6ee47b9d0b267a95679bbcc19dbe8acdb25797de (patch)
tree32eaeb15f47df441343fa9c4ddea767728355993
parent4dbb8f9dca39fac825dba238c4fb0e7e0ef648f3 (diff)
downloadrefcat-6ee47b9d0b267a95679bbcc19dbe8acdb25797de.tar.gz
refcat-6ee47b9d0b267a95679bbcc19dbe8acdb25797de.zip
cdx: add -B best effort flag
-rw-r--r--skate/cmd/skate-cdx-lookup/main.go19
1 files 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)