summaryrefslogtreecommitdiff
path: root/haskell/app/Main.hs
blob: 85b07da53cb6457b1076fb3276ecd85a75cad6ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{-# LANGUAGE OverloadedStrings #-}

module Main (main) where

import Control.Exception
import System.Environment
import System.Posix.Process

import SpaceTraders
import SpaceTraders.Automation.Init
import SpaceTraders.APIClient.Errors
import SpaceTraders.APIClient.Systems
import SpaceTraders.Database.Agents
import SpaceTraders.Database.Contracts
import SpaceTraders.Database.Ships

main :: IO ()
main = do
  env <- initST
  runSpaceTradersT getAgent env >>= print
  s <- runSpaceTradersT initSystems env
  case s of
    Left (APIResetHappened _) -> do
      p <- getExecutablePath
      a <- getArgs
      e <- getEnvironment
      executeFile p False a (Just e)
    Left e -> throwIO e
    Right s' -> print $ length s'
  runSpaceTradersT getContracts env >>= print
  runSpaceTradersT getShips env >>= print
  deinitST env