-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
63 lines (53 loc) · 1.11 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"bytes"
"embed"
"github.com/arelate/gaugin/cli"
"github.com/arelate/gaugin/rest"
"github.com/boggydigital/clo"
"github.com/boggydigital/nod"
"os"
"sync"
)
var (
once = sync.Once{}
//go:embed "templates/*.gohtml"
templates embed.FS
//go:embed "stencil_app/styles/css.gohtml"
stencilAppStyles embed.FS
//go:embed "cli-commands.txt"
cliCommands []byte
//go:embed "cli-help.txt"
cliHelp []byte
)
func main() {
nod.EnableStdOutPresenter()
gs := nod.Begin("gaugin is serving vangogh data")
defer gs.End()
once.Do(func() {
if err := rest.Init(templates, stencilAppStyles); err != nil {
_ = gs.EndWithError(err)
os.Exit(1)
}
})
defs, err := clo.Load(
bytes.NewBuffer(cliCommands),
bytes.NewBuffer(cliHelp),
nil)
if err != nil {
_ = gs.EndWithError(err)
os.Exit(1)
}
clo.HandleFuncs(map[string]clo.Handler{
"serve": cli.ServeHandler,
"version": cli.VersionHandler,
})
if err := defs.AssertCommandsHaveHandlers(); err != nil {
_ = gs.EndWithError(err)
os.Exit(1)
}
if err := defs.Serve(os.Args[1:]); err != nil {
_ = gs.EndWithError(err)
os.Exit(1)
}
}