aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2018-04-08 08:51:26 -0700
committerAdam Mathes <adam@trenchant.org>2018-04-08 08:51:26 -0700
commitcd1509967d7dafbf2d1a051206e368bd3aa5e179 (patch)
treedbcf7629eaaa3e04409c1c949072ebaf06d9436e /main.go
parente0702a70437eea543aaa51264272dcbc3d652779 (diff)
downloadneko-cd1509967d7dafbf2d1a051206e368bd3aa5e179.tar.gz
neko-cd1509967d7dafbf2d1a051206e368bd3aa5e179.tar.bz2
neko-cd1509967d7dafbf2d1a051206e368bd3aa5e179.zip
refactor exporter, add json/opml export formats
Diffstat (limited to 'main.go')
-rw-r--r--main.go32
1 files changed, 7 insertions, 25 deletions
diff --git a/main.go b/main.go
index b7aefb3..40f2647 100644
--- a/main.go
+++ b/main.go
@@ -3,30 +3,28 @@ package main
import (
"adammathes.com/neko/config"
"adammathes.com/neko/crawler"
+ "adammathes.com/neko/exporter"
"adammathes.com/neko/models"
"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, opml bool
- var configFile, newFeed string
+ var serve, update, verbose bool
+ var configFile, newFeed, export string
flag.StringVarP(&configFile, "config", "c", "config.json", "`configuration` file")
flag.BoolVarP(&update, "update", "u", false, "fetch feeds and store them in the database")
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.StringVarP(&export, "export", "x", "", "export feeds as `text`, json or opml")
flag.Parse()
// no command
- if !update && !serve && !printFeeds && !opml && newFeed == "" {
+ if !update && !serve && newFeed == "" && export == "" {
flag.Usage()
return
}
@@ -45,23 +43,7 @@ func main() {
if newFeed != "" {
feed.NewFeed(newFeed)
}
- if printFeeds {
- feeds, err := feed.All()
- if err != nil {
- panic(err)
- }
- for _, f := range feeds {
- 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>`)
+ if export != "" {
+ exporter.ExportFeeds(export)
}
}