2019-12-02 14:31:00 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-12-04 17:30:01 +00:00
|
|
|
"flag"
|
2019-12-02 16:24:19 +00:00
|
|
|
"fmt"
|
|
|
|
|
2019-12-02 14:31:00 +00:00
|
|
|
"git.sr.ht/~emersion/koushin"
|
2019-12-04 17:30:01 +00:00
|
|
|
"github.com/labstack/echo/v4"
|
2019-12-02 14:31:00 +00:00
|
|
|
"github.com/labstack/echo/v4/middleware"
|
2019-12-04 17:30:01 +00:00
|
|
|
"github.com/labstack/gommon/log"
|
2019-12-02 14:31:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2019-12-04 17:30:01 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-12-04 17:30:01 +00:00
|
|
|
flag.Parse()
|
2019-12-02 16:24:19 +00:00
|
|
|
|
2019-12-04 17:30:01 +00:00
|
|
|
if flag.NArg() < 1 || flag.NArg() > 2 {
|
|
|
|
flag.Usage()
|
|
|
|
return
|
2019-12-03 14:21:59 +00:00
|
|
|
}
|
|
|
|
|
2019-12-04 17:30:01 +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"))
|
|
|
|
}
|