forked from eXeC64/nanolist
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
36 lines (28 loc) · 878 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
package main
import (
"gopkg.in/alecthomas/kingpin.v2"
"log"
"os"
"github.com/peterverraedt/tinylist/list"
)
func main() {
err := run(os.Args[1:])
if err != nil {
log.Fatal(err)
}
}
func run(params []string) error {
backend := NewSQLBackend()
app := kingpin.New("tinylist", "Tiny list server")
app.HelpFlag.Short('h')
debug := app.Flag("debug", "Don't send emails - print them to stdout instead").Bool()
configFile := app.Flag("config", "Load configuration from specified file").Default("").String()
app.Command("check", "Check the configuration").Action(backend.check)
app.Command("message", "Process a message from stdin").Action(backend.message)
list.AddCommand(app, true, "", list.NewBotFactory(backend))
app.Action(func(*kingpin.ParseContext) error {
return backend.LoadConfig(*configFile, *debug)
})
_, err := app.Parse(params)
return err
}