-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (35 loc) · 976 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
34
35
36
37
38
39
40
41
42
package main
import (
"flag"
"github.com/alecthomas/kong"
"k8s.io/klog/v2"
)
// Globals are global flags that can be set for all subcommands
type Globals struct {
Root string `help:"Set the root directory for the site"`
}
// CLI defines the subcommands and flags supported
type CLI struct {
Globals
Post postCmd `cmd:"" help:"Create a post"`
Render renderCmd `cmd:"" help:"Render output to a static directory"`
Dev devCmd `cmd:"" help:"Developer mode: local webserver with instant rendering"`
Init initCmd `cmd:"" help:"Initialize a site directory"`
}
func main() {
klog.InitFlags(nil)
flag.Set("logtostderr", "false")
flag.Set("alsologtostderr", "true")
flag.Parse()
cli := CLI{}
ctx := kong.Parse(&cli,
kong.Name("nykya"),
kong.Description("nykya personal site generator"),
kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{
Compact: true,
Summary: true,
}))
err := ctx.Run(&cli.Globals)
ctx.FatalIfErrorf(err)
}