aboutsummaryrefslogblamecommitdiffstats
path: root/main.go
blob: 26dd1fc14183cd28b9e182ae960da2cbdb8e4ca6 (plain) (tree)
1
2
3
4
5
6
7
8
9


            
              
                                    
                                        


                                         
             


             





                                                                                
 


                                                                                    
                                              




                               
                                             


                                     
         
                  

                                                                                
         


                               
 
package main

import (
	"flag"
	"adammathes.com/neko/config"
	"adammathes.com/neko/crawler"	
	"adammathes.com/neko/models"
	"adammathes.com/neko/models/feed"
	"adammathes.com/neko/web"
	"log"
)

func main() {
	var serve, update bool
	var configFile, newFeed string
	
	flag.StringVar(&configFile, "c", "config.json", "`configuration` file")
	flag.BoolVar(&update, "update", false, "update items by fetching feeds")
	flag.BoolVar(&serve, "serve", false, "run http server")

	flag.StringVar(&newFeed, "add", "", "add feed `http://example.com/rss.xml`")
	flag.Parse()

	if !update && !serve && newFeed == ""{
		flag.Usage()
		return 
	}

	config.Read(configFile)
	models.InitDB(config.Config.DBServer)

	if newFeed != "" {
		feed.NewFeed(newFeed)
	}
	if serve {
		log.Printf("starting web server at %s", config.Config.WebServer)
		web.Serve()
	}
	if update {
		crawler.Crawl()
	}	
}