diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-04-21 13:25:51 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-04-21 13:25:51 -0400 |
commit | 360d8ac4601dc5b48c22eeb93eb1853cee99e6c9 (patch) | |
tree | 57b1e55c818dc45862cb5375e541f7efee829530 /CmdLine.hs | |
parent | e336a4fdf3d55f01b8c2871ceb906544a493eeb7 (diff) | |
download | debug-me-360d8ac4601dc5b48c22eeb93eb1853cee99e6c9.tar.gz |
http server scaffolding
Diffstat (limited to 'CmdLine.hs')
-rw-r--r-- | CmdLine.hs | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -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 |