This repository has been archived by the owner on Jun 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
81 lines (72 loc) · 1.81 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
77
78
79
80
81
package main
import (
"os"
"github.com/Sirupsen/logrus"
"github.com/gitlawr/cihelper/cmd"
"github.com/urfave/cli"
)
var VERSION = "dev"
var AppHelpTemplate = `{{.Usage}}
Usage: {{.Name}} {{if .Flags}}[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: cihelper [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 = "cihelper"
app.Usage = "Tool for smoothing ci in rancher"
app.Before = func(ctx *cli.Context) error {
if ctx.GlobalBool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
return nil
}
app.Version = VERSION
app.Author = "Rancher Labs, Inc."
app.Email = ""
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug",
Usage: "Debug logging",
},
cli.StringFlag{
Name: "envurl",
Usage: "Environment ENDPOINT URL",
EnvVar: "CATTLE_URL",
},
cli.StringFlag{
Name: "accesskey",
Usage: "Environment ACCESS KEY",
EnvVar: "CATTLE_ACCESS_KEY",
},
cli.StringFlag{
Name: "secretkey",
Usage: "Environment SECRET KEY",
EnvVar: "CATTLE_SECRET_KEY",
},
}
app.Commands = []cli.Command{
cmd.PushImageCommand(),
cmd.UpgradeCommand(),
cmd.MergeYamlCommand(),
}
err := app.Run(os.Args)
if err != nil {
logrus.Fatal(err)
}
}