From 60bde7009cb492d5ea204e909e1fabc68a7d32f2 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Fri, 17 Jun 2022 23:12:18 +0200 Subject: make connstring configurable at runtime --- app/Main.hs | 8 ++++- haskell-gtfs.cabal | 95 ------------------------------------------------------ tracktrain.cabal | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 96 deletions(-) delete mode 100644 haskell-gtfs.cabal create mode 100644 tracktrain.cabal 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/haskell-gtfs.cabal deleted file mode 100644 index ec312ee..0000000 --- a/haskell-gtfs.cabal +++ /dev/null @@ -1,95 +0,0 @@ -cabal-version: 2.4 -name: tracktrain -version: 0.1.0.0 - --- A short (one-line) description of the package. -synopsis: tracktrain tracks trains on their traintracks - --- A longer description of the package. --- description: - --- A URL where users can report bugs. --- bug-reports: - --- The license under which the package is released. --- license: -author: stuebinm -maintainer: stuebinm@disroot.org - --- A copyright notice. --- copyright: --- category: -extra-source-files: CHANGELOG.md - -executable tracktrain - main-is: Main.hs - build-depends: base ^>=4.14.3.0 - , bytestring >= 0.10.10.0 - , fmt >= 0.6.3.0 - , time >= 1.9 - , aeson - , tracktrain - , wai-extra - , warp - , data-default-class >= 0.1.2 - , persistent-postgresql - , monad-logger - hs-source-dirs: app - default-language: Haskell2010 - default-extensions: OverloadedStrings - , ScopedTypeVariables - --- executable gen-js --- main-is: GenJS.hs --- build-depends: base ^>=4.14.3.0 --- , servant-js --- , tracktrain --- , universum --- hs-source-dirs: app --- default-language: Haskell2010 --- default-extensions: OverloadedStrings --- , ScopedTypeVariables --- , NoImplicitPrelude - - -library - build-depends: base ^>=4.14.3.0 - , zip-archive - , cassava >= 0.5.2.0 - , bytestring >= 0.10.10.0 - , vector >= 0.12.3.1 - , regex-tdfa - , text - , fmt >= 0.6.3.0 - , time >= 1.9 - , aeson - , servant - , servant-server - , warp - , uuid >= 1.3 - , stm - , containers >= 0.6.5 - , swagger2 - , servant-swagger - , servant-docs - , lens - , persistent - , persistent-postgresql - , monad-logger - , mtl - , unliftio-core - , conduit - , path-pieces - , either - , resource-pool - , transformers - , extra - hs-source-dirs: lib - exposed-modules: GTFS - , Server - , PersistOrphans - , Persist - , API - default-language: Haskell2010 - default-extensions: OverloadedStrings - , ScopedTypeVariables diff --git a/tracktrain.cabal b/tracktrain.cabal new file mode 100644 index 0000000..ec312ee --- /dev/null +++ b/tracktrain.cabal @@ -0,0 +1,95 @@ +cabal-version: 2.4 +name: tracktrain +version: 0.1.0.0 + +-- A short (one-line) description of the package. +synopsis: tracktrain tracks trains on their traintracks + +-- A longer description of the package. +-- description: + +-- A URL where users can report bugs. +-- bug-reports: + +-- The license under which the package is released. +-- license: +author: stuebinm +maintainer: stuebinm@disroot.org + +-- A copyright notice. +-- copyright: +-- category: +extra-source-files: CHANGELOG.md + +executable tracktrain + main-is: Main.hs + build-depends: base ^>=4.14.3.0 + , bytestring >= 0.10.10.0 + , fmt >= 0.6.3.0 + , time >= 1.9 + , aeson + , tracktrain + , wai-extra + , warp + , data-default-class >= 0.1.2 + , persistent-postgresql + , monad-logger + hs-source-dirs: app + default-language: Haskell2010 + default-extensions: OverloadedStrings + , ScopedTypeVariables + +-- executable gen-js +-- main-is: GenJS.hs +-- build-depends: base ^>=4.14.3.0 +-- , servant-js +-- , tracktrain +-- , universum +-- hs-source-dirs: app +-- default-language: Haskell2010 +-- default-extensions: OverloadedStrings +-- , ScopedTypeVariables +-- , NoImplicitPrelude + + +library + build-depends: base ^>=4.14.3.0 + , zip-archive + , cassava >= 0.5.2.0 + , bytestring >= 0.10.10.0 + , vector >= 0.12.3.1 + , regex-tdfa + , text + , fmt >= 0.6.3.0 + , time >= 1.9 + , aeson + , servant + , servant-server + , warp + , uuid >= 1.3 + , stm + , containers >= 0.6.5 + , swagger2 + , servant-swagger + , servant-docs + , lens + , persistent + , persistent-postgresql + , monad-logger + , mtl + , unliftio-core + , conduit + , path-pieces + , either + , resource-pool + , transformers + , extra + hs-source-dirs: lib + exposed-modules: GTFS + , Server + , PersistOrphans + , Persist + , API + default-language: Haskell2010 + default-extensions: OverloadedStrings + , ScopedTypeVariables -- cgit v1.2.3