blob: b7f76f32fa3576f19afb7cdb8c7ffc91f4cbcaa1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package main
import (
"fmt"
"github.com/adammathes/neko/config"
"github.com/adammathes/neko/crawler"
"github.com/adammathes/neko/importer"
"github.com/adammathes/neko/models"
"github.com/adammathes/neko/models/feed"
"github.com/adammathes/neko/web"
"log"
"os"
)
func main() {
// TODO: change this
config.Read("./config.json")
models.InitDB(config.Config.DBServer)
if len(os.Args) < 2 {
fmt.Printf("usage: neko [web|addfeed|crawl]\n")
fmt.Printf("addfeed <url> -- add a new feed from <url>\n")
return
}
cmd := os.Args[1]
switch cmd {
case "web":
log.Printf("starting web server at %s", config.Config.WebServer)
web.Serve()
case "addfeed":
addFeed()
case "crawl":
crawl()
case "import":
importLegacy()
default:
panic("not a valid command")
}
}
func addFeed() {
if len(os.Args) < 2 {
log.Fatal("need a valid url")
}
url := os.Args[2]
feed.NewFeed(url)
}
func importLegacy() {
json_file := os.Args[2]
log.Printf("importing json file from: %s", json_file)
importer.ImportJSON(json_file)
}
func crawl() {
crawler.Crawl()
}
|