alps/cmd/koushin/main.go

44 lines
870 B
Go
Raw Normal View History

2019-12-02 14:31:00 +00:00
package main
import (
"flag"
2019-12-02 16:24:19 +00:00
"fmt"
2019-12-02 14:31:00 +00:00
"git.sr.ht/~emersion/koushin"
"github.com/labstack/echo/v4"
2019-12-02 14:31:00 +00:00
"github.com/labstack/echo/v4/middleware"
"github.com/labstack/gommon/log"
_ "git.sr.ht/~emersion/koushin/plugins/base"
2019-12-02 14:31:00 +00:00
)
func main() {
var options koushin.Options
flag.StringVar(&options.Theme, "theme", "", "default theme")
flag.Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(), "usage: koushin [options...] <IMAP URL> [SMTP URL]\n")
flag.PrintDefaults()
2019-12-02 16:24:19 +00:00
}
flag.Parse()
2019-12-02 16:24:19 +00:00
if flag.NArg() < 1 || flag.NArg() > 2 {
flag.Usage()
return
2019-12-03 14:21:59 +00:00
}
options.IMAPURL = flag.Arg(0)
options.SMTPURL = flag.Arg(1)
e := echo.New()
if l, ok := e.Logger.(*log.Logger); ok {
l.SetHeader("${time_rfc3339} ${level}")
}
if err := koushin.New(e, &options); err != nil {
e.Logger.Fatal(err)
}
2019-12-02 14:31:00 +00:00
e.Use(middleware.Recover())
e.Logger.Fatal(e.Start(":1323"))
}