-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
58 lines (51 loc) · 1.57 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
package main
import (
"fmt"
"os"
"github.com/chroju/nature-remo-cli/commands"
"github.com/mitchellh/cli"
)
const (
app = "remo"
version = "0.3.0"
)
func main() {
c := cli.NewCLI(app, version)
c.Args = os.Args[1:]
ui := &cli.BasicUi{
Reader: os.Stdin,
Writer: os.Stdout,
ErrorWriter: os.Stderr,
}
c.Commands = map[string]cli.CommandFactory{
"init": func() (cli.Command, error) {
return &commands.InitCommand{UI: ui}, nil
},
"aircon": func() (cli.Command, error) {
return &commands.AirconCommand{UI: &cli.ColoredUi{Ui: ui, ErrorColor: cli.UiColorRed}}, nil
},
"aircon list": func() (cli.Command, error) {
return &commands.AirconListCommand{UI: &cli.ColoredUi{Ui: ui, ErrorColor: cli.UiColorRed}}, nil
},
"aircon send": func() (cli.Command, error) {
return &commands.AirconSendCommand{UI: &cli.ColoredUi{Ui: ui, ErrorColor: cli.UiColorRed}}, nil
},
"signal": func() (cli.Command, error) {
return &commands.SignalCommand{UI: &cli.ColoredUi{Ui: ui, ErrorColor: cli.UiColorRed}}, nil
},
"signal list": func() (cli.Command, error) {
return &commands.SignalListCommand{UI: &cli.ColoredUi{Ui: ui, ErrorColor: cli.UiColorRed}}, nil
},
"signal send": func() (cli.Command, error) {
return &commands.SignalSendCommand{UI: &cli.ColoredUi{Ui: ui, ErrorColor: cli.UiColorRed}}, nil
},
"sync": func() (cli.Command, error) {
return &commands.SyncCommand{UI: &cli.ColoredUi{Ui: ui, ErrorColor: cli.UiColorRed}}, nil
},
}
exitStatus, err := c.Run()
if err != nil {
ui.Error(fmt.Sprintf("Error: %s", err))
}
os.Exit(exitStatus)
}