From 556f1c98528c4523c4095b438b9436ade5e0d84b Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Wed, 4 Jul 2018 13:16:52 -0700 Subject: wip, simplifications --- main.go | 54 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 16 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index afa34e7..56b0ba7 100644 --- a/main.go +++ b/main.go @@ -12,42 +12,64 @@ import ( ) func main() { - var serve, update, verbose bool - var configFile, newFeed, export string + var help, update, verbose, proxyImages bool + var dbfile, newFeed, export, password string + var port int - 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") + // dbfile + // port + // proxyImages + // username + // password + + flag.BoolVarP(&help, "help", "h", false, "print usage information") + + flag.BoolVarP(&update, "update", "u", false, "fetch feeds and store new items") 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.StringVarP(&export, "export", "x", "", "export feed. format required: text, json or opml") + + // flag.BoolVarP(&serve, "serve", "s", false, "run neko app by starting HTTP server") + + flag.StringVarP(&dbfile, "db", "d", "neko.db", "sqlite database file") + flag.StringVarP(&dbfile, "password", "p", "", "password to access web interface") + + flag.IntVarP(&port, "http", "s", 4994, "HTTP port to serve on") + flag.BoolVarP(&verbose, "verbose", "v", true, "verbose output") + flag.BoolVarP(&proxyImages, "imageproxy", "i", false, "rewrite and proxy all image requests for privacy (experimental)") + flag.Parse() - // no command - if !update && !serve && newFeed == "" && export == "" { + if help { flag.Usage() return } - config.Read(configFile) - models.InitDB() vlog.VERBOSE = verbose + config.Config.DBFile = dbfile + config.Config.Port = port + config.Config.ProxyImages = proxyImages + config.Config.DigestPassword = password + + models.InitDB() if update { vlog.Printf("starting crawl\n") crawler.Crawl() - } - if serve { - vlog.Printf("starting web server at %s\n", - config.Config.WebServer) - web.Serve() + return } if newFeed != "" { vlog.Printf("creating new feed\n") feed.NewFeed(newFeed) + return } if export != "" { vlog.Printf("feed export\n") exporter.ExportFeeds(export) + return } + + vlog.Printf("starting web server at 127.0.0.1:%d\n", + config.Config.Port) + web.Serve() + } -- cgit v1.2.3