-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrhythm.go
71 lines (66 loc) · 1.91 KB
/
rhythm.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
package main
import (
"os"
"github.com/mitchellh/cli"
"github.com/mlowicki/rhythm/command"
"github.com/onrik/logrus/filename"
log "github.com/sirupsen/logrus"
)
func init() {
log.AddHook(filename.NewHook())
}
const version = "0.18"
func main() {
ui := &cli.BasicUi{
Reader: os.Stdin,
Writer: os.Stdout,
ErrorWriter: os.Stderr,
}
coloredUi := &cli.ColoredUi{
Ui: ui,
ErrorColor: cli.UiColorRed,
}
c := cli.NewCLI("rhythm", version)
c.Args = os.Args[1:]
baseCmd := command.BaseCommand{Ui: coloredUi}
c.Commands = map[string]cli.CommandFactory{
"server": func() (cli.Command, error) {
return &command.ServerCommand{BaseCommand: &baseCmd, Version: version}, nil
},
"health": func() (cli.Command, error) {
return &command.HealthCommand{BaseCommand: &baseCmd}, nil
},
"create-job": func() (cli.Command, error) {
return &command.CreateJobCommand{BaseCommand: &baseCmd}, nil
},
"update-job": func() (cli.Command, error) {
return &command.UpdateJobCommand{BaseCommand: &baseCmd}, nil
},
"read-job": func() (cli.Command, error) {
return &command.ReadJobCommand{BaseCommand: &baseCmd}, nil
},
"delete-job": func() (cli.Command, error) {
return &command.DeleteJobCommand{BaseCommand: &baseCmd}, nil
},
"run-job": func() (cli.Command, error) {
return &command.RunJobCommand{BaseCommand: &baseCmd}, nil
},
"find-jobs": func() (cli.Command, error) {
return &command.FindJobsCommand{BaseCommand: &baseCmd}, nil
},
"read-tasks": func() (cli.Command, error) {
return &command.ReadTasksCommand{BaseCommand: &baseCmd}, nil
},
"update-token": func() (cli.Command, error) {
return &command.UpdateTokenCommand{BaseCommand: &baseCmd}, nil
},
"client": func() (cli.Command, error) {
return &command.ClientCommand{BaseCommand: &baseCmd, Version: version}, nil
},
}
exitStatus, err := c.Run()
if err != nil {
log.Error(err)
}
os.Exit(exitStatus)
}