This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
76 lines (65 loc) · 1.83 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
68
69
70
71
72
73
74
75
76
package main
import (
"os"
"github.com/rancher/kontainer-engine/cmd"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
)
// VERSION defines the cli version
var VERSION = "v0.0.0-dev"
var appHelpTemplate = `{{.Usage}}
Usage: {{.Name}} {{if .Flags}}[GLOBAL_OPTIONS] {{end}}COMMAND [arg...]
Version: {{.Version}}
{{if .Flags}}
Options:
{{range .Flags}}{{if .Hidden}}{{else}}{{.}}
{{end}}{{end}}{{end}}
Commands:
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
{{end}}
Run '{{.Name}} COMMAND --help' for more information on a command.
`
var commandHelpTemplate = `{{.Usage}}
{{if .Description}}{{.Description}}{{end}}
Usage: kontainer-engine [global options] {{.Name}} {{if .Flags}}[OPTIONS] {{end}}{{if ne "None" .ArgsUsage}}{{if ne "" .ArgsUsage}}{{.ArgsUsage}}{{else}}[arg...]{{end}}{{end}}
{{if .Flags}}Options:{{range .Flags}}
{{.}}{{end}}{{end}}
`
func main() {
cli.AppHelpTemplate = appHelpTemplate
cli.CommandHelpTemplate = commandHelpTemplate
app := cli.NewApp()
app.Name = "kontainer-engine"
app.Version = VERSION
app.Usage = "CLI tool for creating and managing kubernetes clusters"
app.Before = func(ctx *cli.Context) error {
if ctx.GlobalBool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
logrus.Debugf("kontainer-engine version: %v", VERSION)
return nil
}
app.Author = "Rancher Labs, Inc."
app.Commands = []cli.Command{
cmd.CreateCommand(),
cmd.UpdateCommand(),
cmd.InspectCommand(),
cmd.LsCommand(),
cmd.RmCommand(),
cmd.EnvCommand(),
}
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug",
Usage: "Enable verbose logging",
},
cli.StringFlag{
Name: "plugin-listen-addr",
Usage: "The listening address for rpc plugin server",
},
}
if err := app.Run(os.Args); err != nil {
logrus.Fatal(err)
}
}