aboutsummaryrefslogtreecommitdiff
path: root/cmd/koushin
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/koushin')
-rw-r--r--cmd/koushin/main.go33
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"))
}