From d4513abfcc27e8b7cf4f54f3513cdb865e2dcc76 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 10 Feb 2019 22:19:10 +0100 Subject: added function to get state --- cmd/dolmetschctld/telnet.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cmd/dolmetschctld/telnet.go') diff --git a/cmd/dolmetschctld/telnet.go b/cmd/dolmetschctld/telnet.go index 901c226..d6a5c4a 100644 --- a/cmd/dolmetschctld/telnet.go +++ b/cmd/dolmetschctld/telnet.go @@ -74,6 +74,15 @@ func telnetCmdRatio(c *telgo.Client, args []string, sm *StateMachine) bool { return false } +func telnetCmdState(c *telgo.Client, args []string, sm *StateMachine) bool { + if len(args) != 1 { + c.Sayln("usage: state") + return false + } + c.Sayln("current state: %s", sm.GetState()) + return false +} + func telnetQuit(c *telgo.Client, args []string) bool { return true } @@ -88,6 +97,7 @@ func NewTelnetInterface(addr string, sm *StateMachine) (telnet *TelnetInterface, cmdlist := make(telgo.CmdList) cmdlist["lang"] = func(c *telgo.Client, args []string) bool { return telnetCmdLang(c, args, sm) } cmdlist["ratio"] = func(c *telgo.Client, args []string) bool { return telnetCmdRatio(c, args, sm) } + cmdlist["state"] = func(c *telgo.Client, args []string) bool { return telnetCmdState(c, args, sm) } cmdlist["quit"] = telnetQuit telnet.server, err = telgo.NewServer(addr, "dolmetschctl> ", cmdlist, nil) -- cgit v1.2.3