{-# LANGUAGE LambdaCase #-} module Main where import Cana import Cana.Server import Data.Maybe import System.IO import System.Exit import System.Environment main :: IO () main = do configPath <- configPath config <- loadConfig configPath case config of Left err -> printError "Error loading configuration:" err >> exitFailure Right c -> runGeminiServer' c >>= \case Left err -> printError "Server error:" err >> exitFailure Right _ -> return () where configPath = do args <- getArgs return . fromMaybe "cana.xml" $ listToMaybe args printError title err = do hPutStrLn stderr title hPutStrLn stderr err