module NLP.GenI.Server.Flag where
import qualified GHC.Word as Word
import NLP.GenI.Configuration
import NLP.GenI.General (snd3)
serverOptions :: [OptDescr Flag]
serverOptions = nubBySwitches (concatMap snd3 serverOptionsSections)
type OptSection = (String,[OptDescr Flag],[String])
serverOptionsSections :: [OptSection]
serverOptionsSections =
[ ("Core options", optionsForServer, [])
, ("Input", optionsForInputFiles, [])
, ("Algorithm",
(nubBySwitches $ optionsForBuilder ++ optionsForOptimisation),
[])
, ("Morphology", optionsForMorphology, [])
, ("Client parameters", optionsForRequest, ["Subset of parameters the client can pass in"])
]
optionsForServer :: [OptDescr Flag]
optionsForServer =
[ helpOption, verboseOption
, macrosOption, lexiconOption
, Option [] ["port"] (reqArg PortFlg read "INT")
("port to listen on (default " ++ show defaultPort ++ ")")
, Option [] ["host"] (reqArg HostFlg id "HOST")
("which host to bind (default " ++ defaultHost ++ ")")
]
data PortFlg = PortFlg Int deriving (Eq, Show, Typeable)
data HostFlg = HostFlg String deriving (Eq, Show, Typeable)
data ReqMaxSizeFlg = ReqMaxSizeFlg Word.Word64 deriving (Eq, Show, Typeable)
defaultHost :: String
defaultHost = "127.0.0.1"
defaultPort :: Int
defaultPort = 4364
defaultReqMaxSize :: Word.Word64
defaultReqMaxSize = 4194304
optionsForRequest :: [OptDescr Flag]
optionsForRequest =
optionsForBuilder ++ optionsForOptimisation