forked from hashicorp/levant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.go
67 lines (61 loc) · 1.39 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
package main
import (
"fmt"
"os"
"github.com/hashicorp/levant/command"
"github.com/hashicorp/levant/version"
"github.com/mitchellh/cli"
)
// Commands returns the mapping of CLI commands for Levant. The meta parameter
// lets you set meta options for all commands.
func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
if metaPtr == nil {
metaPtr = new(command.Meta)
}
meta := *metaPtr
if meta.UI == nil {
meta.UI = &cli.BasicUi{
Reader: os.Stdin,
Writer: os.Stdout,
ErrorWriter: os.Stderr,
}
}
return map[string]cli.CommandFactory{
"deploy": func() (cli.Command, error) {
return &command.DeployCommand{
Meta: meta,
}, nil
},
"dispatch": func() (cli.Command, error) {
return &command.DispatchCommand{
Meta: meta,
}, nil
},
"plan": func() (cli.Command, error) {
return &command.PlanCommand{
Meta: meta,
}, nil
},
"render": func() (cli.Command, error) {
return &command.RenderCommand{
Meta: meta,
}, nil
},
"scale-in": func() (cli.Command, error) {
return &command.ScaleInCommand{
Meta: meta,
}, nil
},
"scale-out": func() (cli.Command, error) {
return &command.ScaleOutCommand{
Meta: meta,
}, nil
},
"version": func() (cli.Command, error) {
return &command.VersionCommand{
Version: fmt.Sprintf("Levant %s", version.GetHumanVersion()),
UI: meta.UI,
}, nil
},
}
}