-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
33 lines (27 loc) · 875 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
package main
import (
"github.com/alecthomas/kong"
"github.com/vooon/esp-ota-server/server"
)
var opts struct {
Bind string `short:"s" name:"bind" env:"EOBIND" default:":8092" help:"bind address"`
BaseUrl string `short:"u" name:"base-url" env:"EOBASEURL" default:"http://localhost:8092" help:"base url"`
DataDir string `short:"d" name:"data-dir" env:"EODATADIR" required:"true" help:"path to data dir"`
}
func main() {
kctx := kong.Parse(&opts,
kong.Description("ESP8266 & ESP32 Firmware OTA server"),
kong.Configuration(kong.JSON, "/etc/espotad/espotad.json", "~/.config/espotad.json"),
kong.ConfigureHelp(kong.HelpOptions{
Compact: false,
}),
kong.DefaultEnvars("ESPOTA"),
)
config := server.Config{
Bind: opts.Bind,
BaseUrl: opts.BaseUrl,
DataDirPath: opts.DataDir,
}
err := server.Serve(config)
kctx.FatalIfErrorf(err)
}