module Utils where import Control.Monad.Reader import System.Plugins import Data.Version import System.Info import System.Exit import Config instance Show Server where show s = unlines $ ["\tServer:\t\t" ++ (address s), "\tPort:\t\t" ++ (show . portnum $ s), "\tChannels:\t" ++ (show . channels $ s), "\tNickname:\t" ++ (nickname s), "\tPassword:\t*****", -- we don't ever show the password "\tReal name:\t" ++ (realname s) ] instance Show Config where show c = unlines $ ["Command prefixes:\t" ++ (show . commandPrefixes $ c), "Server list:\n\n" ++ (unlines . map show $ servers c) ] getConfig :: IO Config getConfig = do o <- make "Config.hs" [] case o of MakeSuccess _ obj -> do sym <- load_ obj ["."] "config" case sym of LoadSuccess _ v -> do putStrLn "Loaded Config.hs..." return v :: IO Config LoadFailure e -> do putStrLn "Loading of Configuration FAILED:" mapM_ putStrLn e exitWith (ExitFailure 1) MakeFailure e -> do putStrLn "Compilation of Config.HS FAILED:" mapM_ putStrLn e exitWith (ExitFailure 1)