gameServer/Opts.hs
changeset 4905 7842d085acf4
parent 4568 f85243bf890e
child 4932 f11d80bac7ed
equal deleted inserted replaced
4904:0eab727d4717 4905:7842d085acf4
     1 module Opts
     1 module Opts
     2 (
     2 (
     3     getOpts,
     3     getOpts,
     4 ) where
     4 ) where
     5 
     5 
     6 import System.Environment ( getArgs )
     6 import System.Environment
     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