forked from bpicode/fritzctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch_on.go
32 lines (26 loc) · 834 Bytes
/
switch_on.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
package cmd
import (
"github.com/bpicode/fritzctl/assert"
"github.com/bpicode/fritzctl/fritz"
"github.com/mitchellh/cli"
)
type switchOnCommand struct {
}
func (cmd *switchOnCommand) Help() string {
return "Switch on device. Example usage: fritzctl switch on mydevice"
}
func (cmd *switchOnCommand) Synopsis() string {
return "switch on device"
}
func (cmd *switchOnCommand) Run(args []string) int {
assert.StringSliceHasAtLeast(args, 1, "insufficient input: device name expected")
aha := fritz.HomeAutomation(clientLogin())
err := fritz.ConcurrentHomeAutomation(aha).SwitchOn(args...)
assert.NoError(err, "error switching on device(s):", err)
return 0
}
// SwitchOnDevice is a factory creating commands for switching on switches.
func SwitchOnDevice() (cli.Command, error) {
p := switchOnCommand{}
return &p, nil
}