gameServer/Opts.hs
changeset 4588 5ef5415c4ee1
parent 4568 f85243bf890e
child 4905 7842d085acf4
equal deleted inserted replaced
4529:467ab0685890 4588:5ef5415c4ee1
     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.Environment ( getArgs )
     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