summaryrefslogtreecommitdiff
path: root/src/rhctl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rhctl')
-rw-r--r--src/rhctl/switch_control.go1
-rw-r--r--src/rhctl/telnet.go39
2 files changed, 38 insertions, 2 deletions
diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go
index 91cc161..523269f 100644
--- a/src/rhctl/switch_control.go
+++ b/src/rhctl/switch_control.go
@@ -113,6 +113,7 @@ type SwitchControl struct {
func (ctrl *SwitchControl) handleCommand(cmd *Command) {
switch cmd.Type {
case CmdState:
+ cmd.Response <- ctrl.state
case CmdServer:
case CmdSwitch:
if len(cmd.Args) == 0 {
diff --git a/src/rhctl/telnet.go b/src/rhctl/telnet.go
index de98475..e4044ef 100644
--- a/src/rhctl/telnet.go
+++ b/src/rhctl/telnet.go
@@ -22,6 +22,8 @@
package main
import (
+ "sort"
+
"github.com/spreadspace/telgo"
)
@@ -30,8 +32,41 @@ type TelnetInterface struct {
}
func telnetCmdState(c *telgo.Client, args []string, ctrl *SwitchControl) bool {
- ctrl.Commands <- &Command{Type: CmdState}
- // TODO: implement this
+ resp := make(chan interface{})
+ ctrl.Commands <- &Command{Type: CmdState, Response: resp}
+
+ r := <-resp
+ switch r.(type) {
+ case error:
+ c.Sayln("%v", r)
+ case State:
+ s := r.(State)
+ c.Sayln("Mood: %v", s.Mood)
+
+ c.Sayln("Switch:")
+ c.Sayln(" audio:") //
+ c.Sayln(" output 1: ? (silence!!)?") //
+ c.Sayln(" output 2: ? (silence!!)?") // TODO: fill this with actual data
+ c.Sayln(" relays: ?") //
+ c.Sayln(" oc: ?") //
+
+ c.Sayln("Server:")
+ var names []string
+ for n, _ := range s.Server {
+ names = append(names, n)
+ }
+ sort.Strings(names)
+ for _, name := range names {
+ if name == s.ActiveServer {
+ c.Say(" * ")
+ } else {
+ c.Say(" ")
+ }
+ c.Sayln("%s(%s): '%s'", name, s.Server[name].Health, s.Server[name].Channel)
+ }
+ default:
+ c.Sayln("invalid response of type %T: %+v", r, r)
+ }
return false
}