module Role.Watcher where import Types import Log import Pty import CmdLine import SessionID import Control.Concurrent.STM import Control.Concurrent.STM.TMChan import Role.Developer (run', processSessionStart, getServerMessage, emitOutput) run :: WatchOpts -> IO () run = run' watcher . watchUrl watcher :: TMChan (Message Entered) -> TMChan LogMessage -> SessionID -> IO () watcher _ichan ochan _ = inRawMode $ do (st, startoutput) <- processSessionStart ochan nullLogger emitOutput startoutput go st where go st = do v <- atomically $ getServerMessage ochan st case v of Nothing -> return () Just (o, _msg) -> do emitOutput o go st