forked from pubgo/lava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
52 lines (46 loc) · 1.41 KB
/
Copy pathmain.go
File metadata and controls
52 lines (46 loc) · 1.41 KB
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
package main
import (
"context"
"fmt"
"github.com/pubgo/funk/v2/assert"
"github.com/pubgo/funk/v2/buildinfo/version"
"github.com/pubgo/funk/v2/recovery"
"github.com/pubgo/redant"
"github.com/pubgo/lava/v2/cmds/curlcmd"
"github.com/pubgo/lava/v2/cmds/devproxycmd"
"github.com/pubgo/lava/v2/cmds/fileservercmd"
"github.com/pubgo/lava/v2/cmds/tunnelcmd"
"github.com/pubgo/lava/v2/cmds/watchcmd"
"github.com/pubgo/lava/v2/core/lavabuilder"
"github.com/pubgo/lava/v2/core/signals"
"github.com/pubgo/lava/v2/pkg/cliutil"
)
func main() {
defer recovery.Exit()
// 创建主命令
di := lavabuilder.New()
app := &redant.Command{
Use: "lava",
Short: cliutil.UsageDesc("%s service", version.Project()),
Long: "Lava is a microservice integration framework",
Handler: func(ctx context.Context, i *redant.Invocation) error {
fmt.Println("Usage: lava [command] [arguments]")
fmt.Println("Available commands:")
fmt.Println(" watch Watch files for changes and run commands automatically")
fmt.Println(" curl Make HTTP requests to gRPC services")
fmt.Println(" tunnel Tunnel gateway commands")
fmt.Println(" devproxy Local development proxy tool")
return nil
},
// 添加子命令
Children: []*redant.Command{
watchcmd.New(),
curlcmd.New(),
tunnelcmd.New(di),
fileservercmd.New(),
devproxycmd.New(di),
},
}
// 运行命令
assert.Exit(app.Run(signals.Context()))
}