-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathcommands.go
45 lines (39 loc) · 910 Bytes
/
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
package main
import (
stdLog "log"
"os"
"github.com/mitchellh/cli"
"github.com/myENA/consul-backinator/command/backup"
"github.com/myENA/consul-backinator/command/dump"
"github.com/myENA/consul-backinator/command/restore"
)
// package global logger
var logger *stdLog.Logger
// available commands
var cliCommands map[string]cli.CommandFactory
// init command factory
func init() {
// init logger
logger = stdLog.New(os.Stderr, "", stdLog.LstdFlags)
// register sub commands
cliCommands = map[string]cli.CommandFactory{
"backup": func() (cli.Command, error) {
return &backup.Command{
Self: os.Args[0],
Log: logger,
}, nil
},
"restore": func() (cli.Command, error) {
return &restore.Command{
Self: os.Args[0],
Log: logger,
}, nil
},
"dump": func() (cli.Command, error) {
return &dump.Command{
Self: os.Args[0],
Log: logger,
}, nil
},
}
}