diff options
author | Simon Ser <contact@emersion.fr> | 2019-12-04 18:30:01 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-12-04 18:30:01 +0100 |
commit | e94b1311ded705b0af3a6977cf5fb248a9530387 (patch) | |
tree | 9ebf02e45469967c6f05300cfc5436cbee2e850f /cmd | |
parent | 4ab5fb7f65fe8d8f0b291dbead9f0134a28eaba2 (diff) | |
download | alps-e94b1311ded705b0af3a6977cf5fb248a9530387.tar.gz alps-e94b1311ded705b0af3a6977cf5fb248a9530387.zip |
Add basic theme support
References: https://todo.sr.ht/~sircmpwn/koushin/1
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/koushin/main.go | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/cmd/koushin/main.go b/cmd/koushin/main.go index d30cb85..e644884 100644 --- a/cmd/koushin/main.go +++ b/cmd/koushin/main.go @@ -1,28 +1,41 @@ package main import ( + "flag" "fmt" - "os" "git.sr.ht/~emersion/koushin" + "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" + "github.com/labstack/gommon/log" ) func main() { - if len(os.Args) != 2 && len(os.Args) != 3 { - fmt.Println("usage: koushin <IMAP URL> [SMTP URL]") - return + 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() } - imapURL := os.Args[1] + flag.Parse() - var smtpURL string - if len(os.Args) == 3 { - smtpURL = os.Args[2] + if flag.NArg() < 1 || flag.NArg() > 2 { + flag.Usage() + return } - e := koushin.New(imapURL, smtpURL) - e.Use(middleware.Logger()) + 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) + } e.Use(middleware.Recover()) e.Logger.Fatal(e.Start(":1323")) } |