-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
69 lines (61 loc) · 1.3 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
package main
import (
"fmt"
"os"
"github.com/mitchellh/cli"
)
func main() {
ui := &cli.BasicUi{
Reader: os.Stdin,
Writer: os.Stdout,
ErrorWriter: os.Stderr,
}
// CLI stuff
c := cli.NewCLI("ec2-snapper", "0.5.2")
c.Args = os.Args[1:]
c.Commands = map[string]cli.CommandFactory{
"create": func() (cli.Command, error) {
return &CreateCommand{
Ui: &cli.ColoredUi{
Ui: ui,
OutputColor: cli.UiColorNone,
ErrorColor: cli.UiColorRed,
WarnColor: cli.UiColorYellow,
InfoColor: cli.UiColorGreen,
},
}, nil
},
"delete": func() (cli.Command, error) {
return &DeleteCommand{
Ui: &cli.ColoredUi{
Ui: ui,
OutputColor: cli.UiColorNone,
ErrorColor: cli.UiColorRed,
WarnColor: cli.UiColorYellow,
InfoColor: cli.UiColorGreen,
},
}, nil
},
"report": func() (cli.Command, error) {
return &ReportCommand{
Ui: &cli.ColoredUi{
Ui: ui,
OutputColor: cli.UiColorNone,
ErrorColor: cli.UiColorRed,
WarnColor: cli.UiColorYellow,
InfoColor: cli.UiColorGreen,
},
}, nil
},
"version": func() (cli.Command, error) {
return &VersionCommand{
cliRef: *c,
}, nil
},
}
exitStatus, err := c.Run()
if err != nil {
fmt.Println(os.Stderr, err.Error())
}
os.Exit(exitStatus)
}