module Main where
import Network.Loshadka.Server (serve)
import Network.Loshadka.Settings (readSettings)
import System.Environment (getArgs)
import System.Exit (exitFailure)
import Data.List (isInfixOf)
main :: IO()
main = do
as <- getArgs
if null as
then initialize "." as
else let a = head as in
if "help" `isInfixOf` a || "-h" == a
then help
else case last a of
'/' -> initialize (init a) as
_ -> initialize a as
initialize :: String -> [String] -> IO()
initialize path args = do
settings <- readSettings path args
serve settings
help :: IO()
help = do
putStrLn "Usage: loshadka <server_directory> [jar_flags]"
exitFailure