SoccerFunGL-0.5: SoccerFun/UI/GL/RunMatch.hs
{-# LANGUAGE UnicodeSyntax #-}
-- | Usage: Hit /q/ to abort the match
module Main where
import Control.Monad
import System.Exit
import Prelude.Unicode
import Data.Binary
import SoccerFun.MatchGame
import SoccerFun.Tape
import System.Cmd
import System.Environment
import Paths_SoccerFunGL
main ∷ IO ()
main = do
prog ← getProgName
args ← getArgs
let (p1,p2) = case args of
[t1,t2] → (t1,t2)
notTwo → error $ unlines
["Run a match between two teams <Team1> and <Team2>",
"Usage: " ⧺ prog ⧺ " <dir1> <dir2>",
" where both arguments are paths to directories containing a team module."]
(loc1,name1) ← compileTeam p1
(loc2,name2) ← compileTeam p2
runMatch ← getDataFileName "SoccerFun/UI/GL/RunMatch/Template.hs"
exitCode ← system $ "runhaskell -i" ⧺ loc1 ⧺ " -i" ⧺ loc2 ⧺ " -DTEAM1=" ⧺ name1 ⧺ " -DTEAM2=" ⧺ name2 ⧺ " " ⧺ runMatch
when (exitCode ≢ ExitSuccess) (fail "Could merge teams, probably due to a type error.")