-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
67 lines (59 loc) · 1.7 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
58
59
60
61
62
63
64
65
66
67
//go:generate go run pkg/codegen/cleanup/main.go
//go:generate /bin/rm -rf pkg/generated
//go:generate go run pkg/codegen/main.go
package main
import (
"fmt"
"os"
"github.com/aiyengar2/portexporter/cmd/gateway"
"github.com/aiyengar2/portexporter/cmd/proxy"
"github.com/aiyengar2/portexporter/cmd/redirector"
"github.com/aiyengar2/portexporter/cmd/test"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var (
Version = "v0.0.0-dev"
GitCommit = "HEAD"
KubeConfig string
// go:embed description.txt
AppDescription string
)
func main() {
app := cli.NewApp()
app.Name = "portexporter"
app.Version = fmt.Sprintf("%s (%s)", Version, GitCommit)
app.Usage = "A tunnel server and reverse proxy that are powered by rancher/remotedialer"
app.Description = AppDescription
app.CommandNotFound = func(cliCtx *cli.Context, s string) {
fmt.Fprintf(cliCtx.App.Writer, "Invalid Command: %s \n\n", s)
if pcliCtx := cliCtx.Parent(); pcliCtx == nil {
cli.ShowAppHelpAndExit(cliCtx, 1)
} else {
cli.ShowCommandHelpAndExit(cliCtx, pcliCtx.Command.Name, 1)
}
}
app.OnUsageError = func(cliCtx *cli.Context, err error, isSubcommand bool) error {
fmt.Fprintf(cliCtx.App.Writer, "Incorrect Usage: %s \n\n", err.Error())
if isSubcommand {
cli.ShowSubcommandHelp(cliCtx)
} else {
cli.ShowAppHelp(cliCtx)
}
return nil
}
app.Before = func(cliCtx *cli.Context) error {
logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true, FullTimestamp: true})
logrus.SetOutput(cliCtx.App.Writer)
return nil
}
app.Commands = []cli.Command{
gateway.NewCommand(),
proxy.NewCommand(),
redirector.NewCommand(),
test.NewCommand(),
}
if err := app.Run(os.Args); err != nil {
logrus.Fatal(err)
}
}