Beispiel #1
0
func main() {
	app := cli.NewApp()
	app.Name = "novel_client"
	app.Usage = "novel client function aggregation"
	app.Version = VERSION

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "path, d",
			Value: "conf",
			Usage: "conf directory of client",
		},
		cli.StringFlag{
			Name:  "file, f",
			Value: "client.conf",
			Usage: "config file of client",
		},
	}

	app.Commands = []cli.Command{
		{
			Name:  "grab",
			Usage: "grab commands, including site|novel|chapter",
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "wait, w",
					Usage: "if wait for result",
				},
			},
			Subcommands: []cli.Command{
				{
					Name:        "site",
					Usage:       "send grab site commands",
					Description: "[egg: tyread.com]",
					Action: func(c *cli.Context) {
						Init(c.GlobalString("path"), c.GlobalString("file"))
						site := c.Args().Get(0)
						if site == "" {
							cli.ShowCommandHelp(c, "site")
							os.Exit(-1)
						}

						GrabSite(site, c.GlobalBool("wait"))
					},
				},
			},
		},
	}
	app.Action = func(c *cli.Context) {
		cli.ShowAppHelp(c)
	}

	app.Run(os.Args)
	defer env.Close()
}
Beispiel #2
0
func main() {
	if err := env.Load("conf", "scheduler.conf"); err != nil {
		panic(err.Error())
	}
	defer env.Close()

	sch, err := scheduler.NewScheduler()
	if err != nil {
		panic("init scheduler error: " + err.Error())
	}

	sch.Work()

}
Beispiel #3
0
func main() {
	var svr *saver.Saver
	var err error

	if err := env.Load("conf", "saver.conf"); err != nil {
		panic(err.Error())
	}
	defer env.Close()

	if svr, err = saver.NewSaver(); err != nil {
		panic("init saver error : " + err.Error())
	}

	svr.Work()
}