From 5572dbc8289de934e9ee5bc3f74a0f98365ce3e5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 21 Apr 2017 17:42:10 -0400 Subject: initial http server Incomplete, but the client is able to connect and send messages which get logged. Split up debug-me.hs into Role/* Switched from cereal to binary, since websockets operate on lazy ByteStrings, and using cereal would involve a copy on every receive. This commit was sponsored by Boyd Stephen Smith Jr. on Patreon. --- CmdLine.hs | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'CmdLine.hs') diff --git a/CmdLine.hs b/CmdLine.hs index 2c71327..db3c749 100644 --- a/CmdLine.hs +++ b/CmdLine.hs @@ -9,10 +9,19 @@ data CmdLine = CmdLine } data Mode - = Test - | Graphviz GraphvizOpts - | Replay ReplayOpts - | Server ServerOpts + = UserMode UserOpts + | DeveloperMode DeveloperOpts + | GraphvizMode GraphvizOpts + | ReplayMode ReplayOpts + | ServerMode ServerOpts + +data UserOpts = UserOpts + { + } + +data DeveloperOpts = DeveloperOpts + { debugUrl :: String + } data GraphvizOpts = GraphvizOpts { graphvizLogFile :: FilePath @@ -32,10 +41,11 @@ parseCmdLine :: Parser CmdLine parseCmdLine = CmdLine <$> parseMode parseMode :: Parser Mode -parseMode = (Graphviz <$> parsegraphviz) - <|> (Replay <$> parsereplay) - <|> (Server <$> parseserver) - <|> pure Test -- default, so last +parseMode = (GraphvizMode <$> parsegraphviz) + <|> (ReplayMode <$> parsereplay) + <|> (ServerMode <$> parseserver) + <|> (DeveloperMode <$> parsedeveloper) + <|> pure (UserMode (UserOpts {})) -- default, so last where parsegraphviz = GraphvizOpts <$> option str @@ -66,6 +76,12 @@ parseMode = (Graphviz <$> parsegraphviz) <> showDefault <> help "port for server to listen on" ) + parsedeveloper = DeveloperOpts + <$> option str + ( long "debug" + <> metavar "url" + <> help "debug a user on the given url" + ) getCmdLine :: IO CmdLine getCmdLine = execParser opts -- cgit v1.2.3