forked from csghuser/go-gocd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
64 lines (52 loc) · 1.31 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
// GoCD CLI tool
package main
import (
gocli "github.com/drewsonne/go-gocd/cli"
"github.com/drewsonne/go-gocd/gocd"
"github.com/urfave/cli"
"os"
"sort"
)
// GoCDUtilityName is used in help text to identify the gocd cli util by name
const GoCDUtilityName = "gocd"
// GoCDUtilityUsageInstructions providers user facing support on operation of the gocd cli tool. @TODO Expand this content.
const GoCDUtilityUsageInstructions = "CLI Tool to interact with GoCD server"
// Version for the cli tool
var Version string
func main() {
buildCli().Run(os.Args)
}
func buildCli() *cli.App {
app := cli.NewApp()
app.Name = GoCDUtilityName
app.Usage = GoCDUtilityUsageInstructions
app.Version = Version
app.EnableBashCompletion = true
app.Commands = gocli.GetCliCommands()
app.Metadata = map[string]interface{}{}
app.Metadata["c"] = gocli.NewCliClient
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "profile",
EnvVar: gocd.EnvVarDefaultProfile,
},
cli.StringFlag{
Name: "server",
EnvVar: gocd.EnvVarServer,
},
cli.StringFlag{
Name: "username",
EnvVar: gocd.EnvVarUsername,
},
cli.StringFlag{
Name: "password",
EnvVar: gocd.EnvVarPassword,
},
cli.BoolFlag{
Name: "skip_ssl_check",
EnvVar: gocd.EnvVarSkipSsl,
},
}
sort.Sort(cli.CommandsByName(app.Commands))
return app
}