-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
57 lines (51 loc) · 1.12 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
package main
import (
"fmt"
"github.com/SyliusLabs/gh-kit/cmd"
"github.com/SyliusLabs/gh-kit/internal/github"
"go.uber.org/fx"
"os"
)
func main() {
fx.New(
fx.Provide(
fx.Annotate(
cmd.NewRootCmd,
fx.ParamTags(`group:"commands"`),
),
asCommand(cmd.NewPrCmd, "pr"),
asSubCommand(cmd.NewPrMergeCmd, "pr"),
asSubCommand(cmd.NewPrRerunCmd, "pr"),
asCommand(cmd.NewUpmergeCmd, "upmerge"),
asSubCommand(cmd.NewUpmergeCreateCmd, "upmerge"),
asSubCommand(cmd.NewUpmergeMergeCmd, "upmerge"),
github.NewCli,
github.NewClient,
github.NewRestClient,
github.NewRepository,
),
fx.Invoke(func(rootCmd *cmd.RootCmd) {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
os.Exit(0)
}),
fx.NopLogger,
).Run()
}
func asCommand(f any, name string) any {
return fx.Annotate(
f,
fx.As(new(cmd.Command)),
fx.ResultTags(`group:"commands"`),
fx.ParamTags(fmt.Sprintf(`group:"%s_subcommands"`, name)),
)
}
func asSubCommand(f any, parentName string) any {
return fx.Annotate(
f,
fx.As(new(cmd.Command)),
fx.ResultTags(fmt.Sprintf(`group:"%s_subcommands"`, parentName)),
)
}