summaryrefslogtreecommitdiff
path: root/src/rhctl/audio_switch_command.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-03-31 23:44:33 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2016-03-31 23:44:33 (GMT)
commit1e5596d626ebba0c150bea5804378cd35f95387e (patch)
tree3907cdb92ec85a516608a3798d9169dfc14da855 /src/rhctl/audio_switch_command.go
parent6af5989872635b44607657fc1c4ff80b4df20798 (diff)
switch status commands work now
Diffstat (limited to 'src/rhctl/audio_switch_command.go')
-rw-r--r--src/rhctl/audio_switch_command.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/rhctl/audio_switch_command.go b/src/rhctl/audio_switch_command.go
index 693689c..c90b1e4 100644
--- a/src/rhctl/audio_switch_command.go
+++ b/src/rhctl/audio_switch_command.go
@@ -171,3 +171,36 @@ func (c SwitchCmdString) Generate(args ...interface{}) string {
}
return s
}
+
+type SwitchCommand struct {
+ Cmd SwitchCmdString
+ Args []interface{}
+ Response chan<- interface{}
+}
+
+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])
+ }
+ default:
+ return nil, fmt.Errorf("unknown command '%s'", cmd)
+ }
+ return
+}