summaryrefslogtreecommitdiffhomepage
path: root/Role/Watcher.hs
blob: 620733c6654a0e4f659ebb0831bc3b9d76727513 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Role.Watcher where

import Types
import Log
import Pty
import CmdLine
import SessionID

import Control.Concurrent.STM
import Role.Developer (run', processSessionStart, getUserMessage, emitOutput)

run :: WatchOpts -> IO ()
run = run' watcher . watchUrl

watcher :: TChan (Message Entered) -> TChan (Message Seen) -> SessionID -> IO ()
watcher _ichan ochan _ = inRawMode $ do
	st <- processSessionStart ochan nullLogger
	go st
  where
	go st = do
		(o, _msg) <- atomically $ getUserMessage ochan st
		emitOutput o
		go st