-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (51 loc) · 1.06 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
package main
import (
"github.com/davecgh/go-spew/spew"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
"gopkg.in/yaml.v2"
"io/ioutil"
"os"
)
var Version string
var Cfg Config
func init() {
zerolog.SetGlobalLevel(zerolog.TraceLevel)
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
MustLoadConfig()
}
func main() {
if Version != "" {
log.Info().Msgf("Version: %s\t", Version)
}
app := &cli.App{
Name: "greet",
Usage: "fight the loneliness!",
Commands: []*cli.Command{
{
Name: "project",
Aliases: []string{"p"},
Usage: "Scaffolds a new project",
Action: func(ctx *cli.Context) error {
spew.Dump(Cfg)
return nil
},
},
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal().Err(err).Msg("failed to run")
}
}
func MustLoadConfig() {
f, err := ioutil.ReadFile("./scaffold-go.yaml")
if err != nil {
log.Fatal().Err(err).Msg("failed to load config")
}
err = yaml.Unmarshal(f, &Cfg)
if err != nil {
log.Fatal().Err(err).Msg("failed to parse config")
}
}