diff options
Diffstat (limited to 'src/rhctl/audio_switch_command.go')
-rw-r--r-- | src/rhctl/audio_switch_command.go | 33 |
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 +} |