Option parser
This commit is contained in:
parent
7588229fff
commit
10d767157c
@ -32,6 +32,7 @@ executable koodihaaste
|
|||||||
build-depends: base >=4.12 && <4.13
|
build-depends: base >=4.12 && <4.13
|
||||||
, servant
|
, servant
|
||||||
, servant-server
|
, servant-server
|
||||||
|
, optparse-generic
|
||||||
, servant-client
|
, servant-client
|
||||||
, servant-client-core
|
, servant-client-core
|
||||||
, text
|
, text
|
||||||
|
19
src/Main.hs
19
src/Main.hs
@ -1,17 +1,28 @@
|
|||||||
{-# LANGUAGE RecordWildCards #-}
|
{-# LANGUAGE DataKinds #-}
|
||||||
|
{-# LANGUAGE DeriveGeneric #-}
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
{-# LANGUAGE TypeOperators #-}
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import Control.Monad.App
|
import Control.Monad.App
|
||||||
import Data.Config
|
import Data.Config
|
||||||
|
import Data.Language
|
||||||
|
import qualified Data.Text.IO as T
|
||||||
import Network.HTTP.Client.TLS (newTlsManager)
|
import Network.HTTP.Client.TLS (newTlsManager)
|
||||||
|
import Options.Generic
|
||||||
import Servant.Client
|
import Servant.Client
|
||||||
import Server
|
import Server
|
||||||
import qualified Data.Text.IO as T
|
|
||||||
import Data.Language
|
newtype Cmd = Cmd (FilePath <?> "Config path")
|
||||||
|
deriving Generic
|
||||||
|
|
||||||
|
instance ParseRecord Cmd
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
_config <- readConfigFromFile "config.yaml"
|
Cmd (Helpful configPath) <- getRecord "koodihaaste"
|
||||||
|
_config <- readConfigFromFile configPath
|
||||||
manager <- newTlsManager
|
manager <- newTlsManager
|
||||||
_languageModel <- buildModel <$> T.readFile (_training _config)
|
_languageModel <- buildModel <$> T.readFile (_training _config)
|
||||||
let state = App{..}
|
let state = App{..}
|
||||||
|
Loading…
Reference in New Issue
Block a user