gameServer/Opts.hs
branch0.9.14
changeset 4242 5e3c5fe2cb14
parent 3671 a94d1dc4a8d9
child 4295 1f5604cd99be
child 4334 82cfbbab73da
equal deleted inserted replaced
4241:835fd7a0e1bf 4242:5e3c5fe2cb14
     1 module Opts
     1 module Opts
     2 (
     2 (
     3     getOpts,
     3     getOpts,
     4 ) where
     4 ) where
     5 
     5 
     6 import System.Environment
     6 import System
     7 import System.Console.GetOpt
     7 import System.Console.GetOpt
     8 import Network
     8 import Network
     9 import Data.Maybe ( fromMaybe )
     9 import Data.Maybe ( fromMaybe )
    10 import qualified Data.ByteString.Char8 as B
       
    11 
       
    12 import CoreTypes
    10 import CoreTypes
    13 import Utils
    11 import Utils
    14 
    12 
    15 options :: [OptDescr (ServerInfo -> ServerInfo)]
    13 options :: [OptDescr (ServerInfo -> ServerInfo)]
    16 options = [
    14 options = [
    30 
    28 
    31 readDedicated str opts = opts{isDedicated = readDedicated}
    29 readDedicated str opts = opts{isDedicated = readDedicated}
    32     where
    30     where
    33         readDedicated = fromMaybe True (maybeRead str :: Maybe Bool)
    31         readDedicated = fromMaybe True (maybeRead str :: Maybe Bool)
    34 
    32 
    35 readDbLogin str opts = opts{dbLogin = B.pack str}
    33 readDbLogin str opts = opts{dbLogin = str}
    36 readDbPassword str opts = opts{dbPassword = B.pack str}
    34 readDbPassword str opts = opts{dbPassword = str}
    37 readDbHost str opts = opts{dbHost = B.pack str}
    35 readDbHost str opts = opts{dbHost = str}
    38 
    36 
    39 getOpts :: ServerInfo -> IO ServerInfo
    37 getOpts :: ServerInfo -> IO ServerInfo
    40 getOpts opts = do
    38 getOpts opts = do
    41     args <- getArgs
    39     args <- getArgs
    42     case getOpt Permute options args of
    40     case getOpt Permute options args of