-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.go
107 lines (102 loc) · 2.8 KB
/
commands.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package main
import (
"fmt"
"os"
"github.com/coolops-io/coolops/command"
"github.com/coolops-io/coolops/flags"
"github.com/urfave/cli"
)
var GlobalFlags = []cli.Flag{}
var Commands = []cli.Command{
{
Name: "build:new",
Usage: "Notify coolops.io about a new build",
ArgsUsage: "[build name]",
Flags: []cli.Flag{
cli.GenericFlag{
Name: "metadata, m",
Usage: "Information to be sent as field on the Slack message (`name=value`)",
Value: &flags.KeyValueFlag{
Values: make(map[string]string),
},
},
cli.GenericFlag{
Name: "param, p",
Usage: "Build parameters to be injected in the deployment container (`name=value`)",
Value: &flags.KeyValueFlag{
Values: make(map[string]string),
},
},
cli.StringFlag{
Name: "token, t",
Usage: "The project's api token",
EnvVar: "COOLOPS_PROJECT_API_TOKEN",
},
},
Action: command.CmdNewBuild,
},
{
Name: "build:new:circleci",
Usage: "Notify coolops.io about a new build using default conventions for CircleCI builds",
Flags: []cli.Flag{
cli.GenericFlag{
Name: "metadata, m",
Usage: "Information to be sent as field on the Slack message (`name=value`)",
Value: &flags.KeyValueFlag{
Values: make(map[string]string),
},
},
cli.GenericFlag{
Name: "param, p",
Usage: "Build parameters to be injected in the deployment container (`name=value`)",
Value: &flags.KeyValueFlag{
Values: make(map[string]string),
},
},
cli.StringFlag{
Name: "name, n",
Usage: "The build name. By default it's [branch-name]-[build-number]",
},
cli.StringFlag{
Name: "token, t",
Usage: "The project's api token",
EnvVar: "COOLOPS_PROJECT_API_TOKEN",
},
},
Action: command.CmdNewBuildCircleCI,
},
{
Name: "build:new:gitlab",
Usage: "Notify coolops.io about a new build using default conventions for GitLab builds",
Flags: []cli.Flag{
cli.GenericFlag{
Name: "metadata, m",
Usage: "Information to be sent as field on the Slack message (`name=value`)",
Value: &flags.KeyValueFlag{
Values: make(map[string]string),
},
},
cli.GenericFlag{
Name: "param, p",
Usage: "Build parameters to be injected in the deployment container (`name=value`)",
Value: &flags.KeyValueFlag{
Values: make(map[string]string),
},
},
cli.StringFlag{
Name: "name, n",
Usage: "The build name. By default it's [branch-name]-[build-number]",
},
cli.StringFlag{
Name: "token, t",
Usage: "The project's api token",
EnvVar: "COOLOPS_PROJECT_API_TOKEN",
},
},
Action: command.CmdNewBuildGitlab,
},
}
func CommandNotFound(c *cli.Context, command string) {
fmt.Fprintf(os.Stderr, "%s: '%s' is not a %s command. See '%s --help'.", c.App.Name, command, c.App.Name, c.App.Name)
os.Exit(2)
}