aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuebinm2022-06-17 23:12:18 +0200
committerstuebinm2022-06-18 01:32:41 +0200
commit60bde7009cb492d5ea204e909e1fabc68a7d32f2 (patch)
treeb778cd8d8921c2d58831f61c77b262a117caae4a
parent815755861152fb0e3dfdd9b6321f8f74e7bf8515 (diff)
make connstring configurable at runtime
-rw-r--r--app/Main.hs8
-rw-r--r--tracktrain.cabal (renamed from haskell-gtfs.cabal)0
2 files changed, 7 insertions, 1 deletions
diff --git a/app/Main.hs b/app/Main.hs
index e47ffc4..ec4b5e7 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE LambdaCase #-}
+
-- | The main module. Does little more than handle some basic ocnfic, then
-- call the server
module Main where
@@ -11,14 +13,18 @@ import Network.Wai.Handler.Warp (run)
import Network.Wai.Middleware.RequestLogger (OutputFormat (..),
RequestLoggerSettings (..),
mkRequestLogger)
+import System.Environment (getArgs)
+import Data.Functor ((<&>))
+import Data.ByteString.Internal (packChars)
import GTFS
import Server
-connStr = "user=travelynx"
main :: IO ()
main = do
+ connStr <- getArgs <&> \case {[str] -> packChars str; _ -> ""}
+
gtfs <- loadGtfs "./gtfs.zip"
loggerMiddleware <- mkRequestLogger
$ def { outputFormat = Detailed True }
diff --git a/haskell-gtfs.cabal b/tracktrain.cabal
index ec312ee..ec312ee 100644
--- a/haskell-gtfs.cabal
+++ b/tracktrain.cabal