-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
36 lines (30 loc) · 809 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
package main
import (
"context"
"log/slog"
"os"
"os/signal"
"time"
"github.com/alecthomas/kong"
"github.com/lmittmann/tint"
"github.com/utgwkk/aws-iam-policy-sim/internal/cli"
"github.com/utgwkk/aws-iam-policy-sim/internal/slogx"
)
func main() {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()
logHandler := tint.NewHandler(os.Stderr, &tint.Options{
Level: slog.LevelInfo,
TimeFormat: time.DateTime,
})
slog.SetDefault(slog.New(logHandler))
var cli cli.CLI
parser, err := kong.New(&cli)
if err != nil {
slogx.FatalContext(ctx, "failed to initialize kong parser", slog.Any("error", err))
}
if _, err := parser.Parse(os.Args[1:]); err != nil {
slogx.FatalContext(ctx, "failed to parse args", slog.Any("error", err))
}
cli.Do(ctx)
}