-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (33 loc) · 838 Bytes
/
main.go
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
package main
import (
"fmt"
"github.com/WindomZ/go-commander"
"github.com/WindomZ/go-develop-kit/path"
"github.com/WindomZ/lagou-jobs/lagou"
)
func main() {
// lagou-jobs
commander.Program.
Version("v1.0.0")
// lagou-jobs <config-file>
commander.Program.
Command("<config-file>", "load the configuration file.").
Description("add user configuration").
Action(func(c commander.Context) error {
configPath := c.MustString("<config-file>")
if configPath == "." {
configPath = "config.json" // default filename
}
if ok, err := path.IsExist(configPath); err != nil {
return err
} else if !ok {
return fmt.Errorf("no \"%v\" file found", configPath)
}
spider, err := lagou.New(configPath)
if err != nil {
return err
}
return spider.Start()
})
commander.Program.Parse()
}