summaryrefslogtreecommitdiff
path: root/src/rhctl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rhctl')
-rw-r--r--src/rhctl/audio_switch_command.go41
-rw-r--r--src/rhctl/switch_control.go4
-rw-r--r--src/rhctl/telnet.go2
3 files changed, 27 insertions, 20 deletions
diff --git a/src/rhctl/audio_switch_command.go b/src/rhctl/audio_switch_command.go
index c90b1e4..e865a90 100644
--- a/src/rhctl/audio_switch_command.go
+++ b/src/rhctl/audio_switch_command.go
@@ -178,27 +178,34 @@ type SwitchCommand struct {
Response chan<- interface{}
}
+func SwitchCommandParseStatus(args []string) (cmdstr SwitchCmdString, cmdargs []interface{}, err error) {
+ if len(args) == 0 {
+ err = fmt.Errorf("missing argument <status-type>")
+ return
+ }
+ switch args[0] {
+ case "audio":
+ cmdstr = SwitchCmdStatusAudio
+ case "gpi":
+ cmdstr = SwitchCmdStatusGPI
+ case "oc":
+ cmdstr = SwitchCmdStatusOC
+ case "relay":
+ cmdstr = SwitchCmdStatusRelay
+ case "silence":
+ cmdstr = SwitchCmdStatusSilence
+ default:
+ err = fmt.Errorf("unknown status-type: '%s'", args[0])
+ return
+ }
+ return
+}
+
func NewSwitchCommandFromStrings(cmd string, args ...string) (c *SwitchCommand, err error) {
c = &SwitchCommand{}
switch cmd {
case "status":
- if len(args) == 0 {
- return nil, fmt.Errorf("missing argument <status-type>")
- }
- switch args[0] {
- case "audio":
- c.Cmd = SwitchCmdStatusAudio
- case "gpi":
- c.Cmd = SwitchCmdStatusGPI
- case "oc":
- c.Cmd = SwitchCmdStatusOC
- case "relay":
- c.Cmd = SwitchCmdStatusRelay
- case "silence":
- c.Cmd = SwitchCmdStatusSilence
- default:
- return nil, fmt.Errorf("unknown status-type: '%s'", args[0])
- }
+ c.Cmd, c.Args, err = SwitchCommandParseStatus(args)
default:
return nil, fmt.Errorf("unknown command '%s'", cmd)
}
diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go
index ca27b86..f52e9a2 100644
--- a/src/rhctl/switch_control.go
+++ b/src/rhctl/switch_control.go
@@ -63,6 +63,8 @@ type SwitchControl struct {
func (ctrl *SwitchControl) handleCommand(cmd *Command) {
switch cmd.Type {
case CmdStatus:
+ case CmdServer:
+ case CmdSwitch:
if len(cmd.Args) == 0 {
rhl.Printf("SwitchCTRL: ignoring empty raw switch command")
return
@@ -74,8 +76,6 @@ func (ctrl *SwitchControl) handleCommand(cmd *Command) {
}
c.Response = cmd.Response
ctrl.sw.Commands <- c
- case CmdServer:
- case CmdSwitch:
}
}
diff --git a/src/rhctl/telnet.go b/src/rhctl/telnet.go
index c4212e6..e693e70 100644
--- a/src/rhctl/telnet.go
+++ b/src/rhctl/telnet.go
@@ -113,7 +113,7 @@ func telnetCmdSwitch(c *telgo.Client, args []string, ctrl *SwitchControl) bool {
return false
}
resp := make(chan interface{})
- ctrl.Commands <- &Command{Type: CmdStatus, Args: args[1:], Response: resp}
+ ctrl.Commands <- &Command{Type: CmdSwitch, Args: args[1:], Response: resp}
r := <-resp
switch r.(type) {
case error: