summaryrefslogtreecommitdiffhomepage
path: root/Role
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-21 22:35:57 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-21 22:35:57 -0400
commit94a94c36cf0eba38b85b8fb6c360c14abae7031f (patch)
tree0e13740582f22f19aa5bd3c24fa53f3cc7c7ca47 /Role
parent75c8b6b9745ea8e64383e28d3f18b1609be00fa3 (diff)
downloaddebug-me-94a94c36cf0eba38b85b8fb6c360c14abae7031f.tar.gz
added debug-me --watch mode
This commit was sponsored by Ewen McNeill.
Diffstat (limited to 'Role')
-rw-r--r--Role/Watcher.hs25
1 files changed, 25 insertions, 0 deletions
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