From eefdc799b929a4d6407737d281c34dd940e2823f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sat, 20 Jun 2020 22:37:44 +0200 Subject: print-cache: Tool for printing the contents of the cache --- tools/print-cache/print-cache.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tools/print-cache/print-cache.go (limited to 'tools') diff --git a/tools/print-cache/print-cache.go b/tools/print-cache/print-cache.go new file mode 100644 index 0000000..d20963a --- /dev/null +++ b/tools/print-cache/print-cache.go @@ -0,0 +1,36 @@ +package main + +import ( + "flag" + "fmt" + "log" + + "github.com/Necoro/feed2imap-go/internal/feed" +) + +// flags +var ( + cacheFile string = "feed.cache" + feedId string = "" +) + +func init() { + flag.StringVar(&cacheFile, "c", cacheFile, "cache file") + flag.StringVar(&feedId, "i", feedId, "id of the feed") +} + +func main() { + flag.Parse() + + cache, err := feed.LoadCache(cacheFile) + if err != nil { + log.Fatal(err) + } + + fmt.Printf("Cache version %d\n", cache.Version()) + if feedId != "" { + fmt.Print(cache.SpecificInfo(feedId)) + } else { + fmt.Print(cache.Info()) + } +} -- cgit v1.2.3