forked from distribworks/dkron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
57 lines (47 loc) · 1.09 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
// Command that implements the main executable.
package main
import (
"fmt"
"os"
"github.com/hashicorp/go-plugin"
"github.com/mitchellh/cli"
"github.com/victorcoder/dkron/dkron"
)
const (
VERSION = "0.9.7"
)
func main() {
c := cli.NewCLI("dkron", VERSION)
c.Args = os.Args[1:]
c.HelpFunc = cli.BasicHelpFunc("dkron")
ui := &cli.BasicUi{Writer: os.Stdout}
plugins := &Plugins{}
plugins.DiscoverPlugins()
// Make sure we clean up any managed plugins at the end of this
c.Commands = map[string]cli.CommandFactory{
"agent": func() (cli.Command, error) {
return &dkron.AgentCommand{
Ui: ui,
Version: VERSION,
ProcessorPlugins: plugins.Processors,
}, nil
},
"keygen": func() (cli.Command, error) {
return &dkron.KeygenCommand{
Ui: ui,
}, nil
},
"version": func() (cli.Command, error) {
return &dkron.VersionCommand{
Version: VERSION,
Ui: ui,
}, nil
},
}
exitStatus, err := c.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
}
plugin.CleanupClients()
os.Exit(exitStatus)
}