forked from sergeyfrolov/httpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (44 loc) · 857 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
37
38
39
40
41
42
43
44
45
46
package main
import (
"fmt"
"github.com/nisainan/wstunnel/client"
"github.com/nisainan/wstunnel/server"
"github.com/urfave/cli"
_ "go.uber.org/automaxprocs"
"os"
)
func main() {
app := cli.NewApp()
app.Name = "wstunnel"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "type",
Value: "server",
Usage: "run type",
},
cli.StringFlag{
Name: "config",
Value: "$(type).yaml",
Usage: "config file url",
},
}
app.Action = func(c *cli.Context) error {
serverType := c.String("type")
if c.String("config") == "$(type).yaml" {
c.Set("config", fmt.Sprintf("%s.yaml", serverType))
}
switch serverType {
case "client":
return client.Run(c)
case "server":
server.Run(c)
default:
return client.Run(c)
}
return nil
}
err := app.Run(os.Args)
if err != nil {
panic("app run error:" + err.Error())
}
}