-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanage.go
50 lines (45 loc) · 1.02 KB
/
manage.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
package main
import (
"net/http"
"os"
"strconv"
"github.com/darklab8/blog/blog"
"github.com/darklab8/blog/blog/settings"
"github.com/darklab8/blog/blog/settings/logus"
"github.com/darklab8/go-utils/utils/cantil"
)
func main() {
web := func() {
fs := http.FileServer(http.Dir("./build"))
http.Handle("/", fs)
port := 8080
logus.Log.Info("Listening on " + strconv.Itoa(port))
err := http.ListenAndServe(":"+strconv.Itoa(port), nil)
logus.Log.CheckPanic(err, "unable to serve serve")
}
parser := cantil.NewConsoleParser(
[]cantil.Action{
{
Nickname: "build",
Description: "build to static assets: html, css, js files",
Func: func(info cantil.ActionInfo) error {
blog.Builder.BuildAll()
return nil
},
},
{
Nickname: "web",
Description: "for local development",
Func: func(info cantil.ActionInfo) error {
blog.Builder.BuildAll()
web()
return nil
},
},
},
cantil.ParserOpts{
Enverants: settings.Enverants,
},
)
parser.Run(os.Args[1:])
}