From 94a94c36cf0eba38b85b8fb6c360c14abae7031f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 21 Apr 2017 22:35:57 -0400 Subject: added debug-me --watch mode This commit was sponsored by Ewen McNeill. --- Role/Watcher.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Role/Watcher.hs (limited to 'Role/Watcher.hs') diff --git a/Role/Watcher.hs b/Role/Watcher.hs new file mode 100644 index 0000000..110c1ef --- /dev/null +++ b/Role/Watcher.hs @@ -0,0 +1,25 @@ +module Role.Watcher where + +import Types +import Log +import Pty +import CmdLine +import WebSockets +import SessionID + +import Control.Concurrent.STM +import qualified Data.Text as T +import Role.Developer (processSessionStart, getUserMessage, Output(..), emitOutput) + +run :: WatchOpts -> IO () +run os = runClientApp $ clientApp (ConnectMode (T.pack (watchUrl os))) watcher + +watcher :: TChan (Message Entered) -> TChan (Message Seen) -> SessionID -> IO () +watcher _ichan ochan sid = inRawMode $ do + st <- processSessionStart ochan nullLogger + go st + where + go st = do + (o, _msg) <- atomically $ getUserMessage ochan st + emitOutput o + go st -- cgit v1.2.3