aboutsummaryrefslogtreecommitdiff
path: root/tools/print-cache/print-cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'tools/print-cache/print-cache.go')
-rw-r--r--tools/print-cache/print-cache.go36
1 files changed, 36 insertions, 0 deletions
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())
+ }
+}