gameServer/Opts.hs
changeset 3500 af8390d807d6
parent 2966 fab0d8b04bb9
child 3671 a94d1dc4a8d9
equal deleted inserted replaced
3499:66eba4e41b91 3500:af8390d807d6
     5 
     5 
     6 import System
     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 
    10 import CoreTypes
    12 import CoreTypes
    11 import Utils
    13 import Utils
    12 
    14 
    13 options :: [OptDescr (ServerInfo -> ServerInfo)]
    15 options :: [OptDescr (ServerInfo -> ServerInfo)]
    14 options = [
    16 options = [
    28 
    30 
    29 readDedicated str opts = opts{isDedicated = readDedicated}
    31 readDedicated str opts = opts{isDedicated = readDedicated}
    30     where
    32     where
    31         readDedicated = fromMaybe True (maybeRead str :: Maybe Bool)
    33         readDedicated = fromMaybe True (maybeRead str :: Maybe Bool)
    32 
    34 
    33 readDbLogin str opts = opts{dbLogin = str}
    35 readDbLogin str opts = opts{dbLogin = B.pack str}
    34 readDbPassword str opts = opts{dbPassword = str}
    36 readDbPassword str opts = opts{dbPassword = B.pack str}
    35 readDbHost str opts = opts{dbHost = str}
    37 readDbHost str opts = opts{dbHost = B.pack str}
    36 
    38 
    37 getOpts :: ServerInfo -> IO ServerInfo
    39 getOpts :: ServerInfo -> IO ServerInfo
    38 getOpts opts = do
    40 getOpts opts = do
    39     args <- getArgs
    41     args <- getArgs
    40     case getOpt Permute options args of
    42     case getOpt Permute options args of