From 360d8ac4601dc5b48c22eeb93eb1853cee99e6c9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 21 Apr 2017 13:25:51 -0400 Subject: http server scaffolding --- CmdLine.hs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'CmdLine.hs') diff --git a/CmdLine.hs b/CmdLine.hs index cf9e2b7..2c71327 100644 --- a/CmdLine.hs +++ b/CmdLine.hs @@ -2,6 +2,7 @@ module CmdLine where import Data.Monoid import Options.Applicative +import Network.Wai.Handler.Warp (Port) data CmdLine = CmdLine { mode :: Mode @@ -11,6 +12,7 @@ data Mode = Test | Graphviz GraphvizOpts | Replay ReplayOpts + | Server ServerOpts data GraphvizOpts = GraphvizOpts { graphvizLogFile :: FilePath @@ -21,13 +23,19 @@ data ReplayOpts = ReplayOpts { replayLogFile :: FilePath } +data ServerOpts = ServerOpts + { serverDirectory :: FilePath + , serverPort :: Port + } + parseCmdLine :: Parser CmdLine parseCmdLine = CmdLine <$> parseMode parseMode :: Parser Mode parseMode = (Graphviz <$> parsegraphviz) <|> (Replay <$> parsereplay) - <|> pure Test + <|> (Server <$> parseserver) + <|> pure Test -- default, so last where parsegraphviz = GraphvizOpts <$> option str @@ -45,6 +53,19 @@ parseMode = (Graphviz <$> parsegraphviz) <> metavar "logfile" <> help "replay log file" ) + parseserver = ServerOpts + <$> option str + ( long "server" + <> metavar "logdir" + <> help "run server, storing logs in the specified directory" + ) + <*> option auto + ( long "port" + <> metavar "N" + <> value 8080 + <> showDefault + <> help "port for server to listen on" + ) getCmdLine :: IO CmdLine getCmdLine = execParser opts -- cgit v1.2.3