/
main.go
61 lines (52 loc) · 1.42 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
package main
import (
"os"
"github.com/codegangsta/cli"
"github.com/dereulenspiegel/anvil/commands/destroy"
"github.com/dereulenspiegel/anvil/commands/login"
"github.com/dereulenspiegel/anvil/commands/provision"
"github.com/dereulenspiegel/anvil/commands/setup"
"github.com/dereulenspiegel/anvil/commands/status"
testcommand "github.com/dereulenspiegel/anvil/commands/test"
"github.com/dereulenspiegel/anvil/commands/verify"
"github.com/dereulenspiegel/anvil/config"
)
var (
App *cli.App
)
func createFlags() []cli.Flag {
configFlag := cli.StringFlag{
Name: "config, c",
Value: config.DefaultConfigPath,
Usage: "Specify an alternative config file",
EnvVar: "ANVIL_YAML",
}
updateFlag := cli.BoolFlag{
Name: "no-refresh,n",
Usage: "Trust state in local cache and do not update it from driver each run",
EnvVar: "ANVIL_NO_REFRESH",
}
flags := make([]cli.Flag, 0, 5)
flags = append(flags, configFlag, updateFlag)
return flags
}
func createSubCommands(app *cli.App) {
setup.BuildCommand(app)
destroy.BuildCommand(app)
status.BuildCommand(app)
provision.BuildCommand(app)
verify.BuildCommand(app)
testcommand.BuildCommand(app)
login.BuildCommand(app)
}
func main() {
App = cli.NewApp()
App.Flags = createFlags()
App.Name = "Anvil"
App.Author = "Till Klocke"
App.Copyright = "MIT License"
App.Version = "0.0.1-alpha"
App.Usage = "Forge your infrastructure"
createSubCommands(App)
App.Run(os.Args)
}