diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/app/Main.hs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/backend/app/Main.hs b/backend/app/Main.hs index a3d30c2..bec530e 100644 --- a/backend/app/Main.hs +++ b/backend/app/Main.hs @@ -1,3 +1,6 @@ +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ApplicativeDo #-} module Main where import AutoTypes qualified as U @@ -39,6 +42,8 @@ args :: A.Parser Args args = Args <$> cmd' data Cmd = Serve + { serverPort :: Int + } cmd' :: A.Parser Cmd cmd' = @@ -48,7 +53,9 @@ cmd' = ] serveCmd :: A.Parser Cmd -serveCmd = pure Serve +serveCmd = do + serverPort <- A.option A.auto (A.metavar "PORT" <> A.showDefault <> A.value 8081 <> A.long "port" <> A.short 'p' <> A.help "The server port") + pure Serve {..} data Repo = Repo { commits :: [Commit] @@ -195,8 +202,8 @@ main = do repoT <- newEmptyTMVarIO _ <- forkIO do watch repoT root ref A.execParser (A.info (args <**> A.helper) A.idm) >>= \case - Args {cmd = Serve} -> do - W.runEnv 8081 $ \req respond -> do + Args {cmd = Serve {serverPort}} -> do + W.runEnv serverPort $ \req respond -> do case P.parseOnly R.parser (W.rawPathInfo req) of Right (R.SchemaJson path) -> do repo <- atomically (readTMVar repoT) |