-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
37 lines (32 loc) · 762 Bytes
/
main.go
File metadata and controls
37 lines (32 loc) · 762 Bytes
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
package main
import (
"fmt"
"os"
"github.com/alecthomas/kong"
"github.com/Softorize/gac/cmd"
"github.com/Softorize/gac/internal/config"
gacerrors "github.com/Softorize/gac/internal/errors"
)
func main() {
var cli cmd.CLI
kongCtx := kong.Parse(&cli,
kong.Name("gac"),
kong.Description("Google Analytics 4 CLI"),
kong.UsageOnError(),
)
cfg, err := config.Load()
if err != nil {
fmt.Fprintf(os.Stderr, "Warning: could not load config: %v\n", err)
cfg = &config.Config{}
}
ctx := cmd.NewContext(&cli, cfg)
err = kongCtx.Run(ctx)
if err != nil {
hint := gacerrors.HintFrom(err)
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
if hint != "" {
fmt.Fprintf(os.Stderr, "Hint: %s\n", hint)
}
os.Exit(gacerrors.ExitCodeFrom(err))
}
}