-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
96 lines (90 loc) · 1.93 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
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
package main
import (
"fmt"
"os"
"github.com/mitchellh/cli"
"github.com/prokosna/dementor/internal/command"
"github.com/prokosna/dementor/lib"
)
func init() {
// initialize config
err := dementor.InitConf()
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}
func main() {
// CLI
ui := &cli.BasicUi{
Reader: os.Stdin,
Writer: os.Stdout,
ErrorWriter: os.Stderr,
}
cui := &cli.ColoredUi{
Ui: ui,
OutputColor: cli.UiColorGreen,
InfoColor: cli.UiColorCyan,
WarnColor: cli.UiColorYellow,
ErrorColor: cli.UiColorRed,
}
c := cli.NewCLI("dementor", "0.0.1")
c.Args = os.Args[1:]
c.Commands = map[string]cli.CommandFactory{
"authenticate": func() (cli.Command, error) {
return &command.AuthenticateCommand{
Ui: cui,
}, nil
},
"createProject": func() (cli.Command, error) {
return &command.CreateProjectCommand{
Ui: cui,
}, nil
},
"deleteProject": func() (cli.Command, error) {
return &command.DeleteProjectCommand{
Ui: cui,
}, nil
},
"fetchFlowsProject": func() (cli.Command, error) {
return &command.FetchFlowsCommand{
Ui: cui,
}, nil
},
"fetchJobsFlow": func() (cli.Command, error) {
return &command.FetchJobsCommand{
Ui: cui,
}, nil
},
"fetchSchedule": func() (cli.Command, error) {
return &command.FetchScheduleCommand{
Ui: cui,
}, nil
},
"scheduleFlow": func() (cli.Command, error) {
return &command.ScheduleFlowCommand{
Ui: cui,
}, nil
},
"unscheduleFlow": func() (cli.Command, error) {
return &command.UnscheduleFlowCommand{
Ui: cui,
}, nil
},
"uploadProjectZip": func() (cli.Command, error) {
return &command.UploadProjectZipCommand{
Ui: cui,
}, nil
},
"kiss": func() (cli.Command, error) {
return &command.KissCommand{
Ui: cui,
}, nil
},
}
exitStatus, err := c.Run()
if err != nil {
fmt.Fprintf(os.Stderr, err.Error())
}
os.Exit(exitStatus)
}