aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2018-04-07 09:24:06 -0700
committerAdam Mathes <adam@trenchant.org>2018-04-07 09:24:06 -0700
commite0702a70437eea543aaa51264272dcbc3d652779 (patch)
treeff2ee4ae1499cc29628f36bd0374e74a855261cd /main.go
parentc7e4f06d626561859f429c876e186baa75713e9d (diff)
downloadneko-e0702a70437eea543aaa51264272dcbc3d652779.tar.gz
neko-e0702a70437eea543aaa51264272dcbc3d652779.tar.bz2
neko-e0702a70437eea543aaa51264272dcbc3d652779.zip
opml export
Diffstat (limited to 'main.go')
-rw-r--r--main.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/main.go b/main.go
index 34bb869..b7aefb3 100644
--- a/main.go
+++ b/main.go
@@ -7,12 +7,13 @@ import (
"adammathes.com/neko/models/feed"
"adammathes.com/neko/vlog"
"adammathes.com/neko/web"
+ "encoding/xml"
"fmt"
flag "github.com/ogier/pflag"
)
func main() {
- var serve, update, verbose, printFeeds bool
+ var serve, update, verbose, printFeeds, opml bool
var configFile, newFeed string
flag.StringVarP(&configFile, "config", "c", "config.json", "`configuration` file")
@@ -20,11 +21,12 @@ func main() {
flag.BoolVarP(&serve, "serve", "s", false, "run http server")
flag.BoolVarP(&verbose, "verbose", "v", false, "verbose output")
flag.BoolVarP(&printFeeds, "feeds", "f", false, "list all currently crawled feeds")
+ flag.BoolVarP(&opml, "opml", "o", false, "export feed list as opml")
flag.StringVarP(&newFeed, "add", "a", "", "add the feed at URL `http://example.com/rss.xml`")
flag.Parse()
// no command
- if !update && !serve && !printFeeds && newFeed == "" {
+ if !update && !serve && !printFeeds && !opml && newFeed == "" {
flag.Usage()
return
}
@@ -52,4 +54,14 @@ func main() {
fmt.Printf("%s\n", f.Url)
}
}
+ if opml {
+ feeds, _ := feed.All()
+ fmt.Printf(`<opml version="2.0"><head><title>neko feeds</title></head><body>`)
+ fmt.Printf("\n")
+ for _, f := range feeds {
+ b, _ := xml.Marshal(f)
+ fmt.Printf("%s\n", string(b))
+ }
+ fmt.Printf(`</body></opml>`)
+ }
}