aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2017-10-21 10:05:37 -0700
committerAdam Mathes <adam@trenchant.org>2017-10-21 10:05:37 -0700
commitafba4c6de77594f1d121990fc93a6c555e15ed57 (patch)
treeca44a7377e7c0a321d3435d996fc37b2f048c535
parent22f4701bb45a11958c19238de10ef0bf0593894c (diff)
downloadneko-afba4c6de77594f1d121990fc93a6c555e15ed57.tar.gz
neko-afba4c6de77594f1d121990fc93a6c555e15ed57.tar.bz2
neko-afba4c6de77594f1d121990fc93a6c555e15ed57.zip
Switch from default go flag lib to plfag for UNIX/POSIX style flags
ie $ neko --serve $ neko -s $ neko --config=/etc/neko.conf --serve $ neko -c /etc/neko.conf -s $ neko --update --verbose $ neko -uv
-rw-r--r--main.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/main.go b/main.go
index d13efe7..34bb869 100644
--- a/main.go
+++ b/main.go
@@ -1,41 +1,41 @@
package main
import (
- "flag"
"adammathes.com/neko/config"
- "adammathes.com/neko/crawler"
+ "adammathes.com/neko/crawler"
"adammathes.com/neko/models"
"adammathes.com/neko/models/feed"
- "adammathes.com/neko/web"
"adammathes.com/neko/vlog"
+ "adammathes.com/neko/web"
"fmt"
+ flag "github.com/ogier/pflag"
)
func main() {
var serve, update, verbose, printFeeds 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.BoolVar(&verbose, "verbose", false, "verbose output")
- flag.BoolVar(&printFeeds, "feeds", false, "list all currently crawled feeds")
- flag.StringVar(&newFeed, "add", "", "add feed `http://example.com/rss.xml`")
+
+ 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.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 && newFeed == "" {
flag.Usage()
- return
+ return
}
config.Read(configFile)
models.InitDB(config.Config.DBServer)
vlog.VERBOSE = verbose
-
+
if update {
crawler.Crawl()
- }
+ }
if serve {
vlog.Printf("starting web server at %s", config.Config.WebServer)
web.Serve()
@@ -44,11 +44,11 @@ func main() {
feed.NewFeed(newFeed)
}
if printFeeds {
- feeds,err := feed.All()
+ feeds, err := feed.All()
if err != nil {
panic(err)
}
- for _,f := range(feeds) {
+ for _, f := range feeds {
fmt.Printf("%s\n", f.Url)
}
}