diff options
Diffstat (limited to 'haskell/app')
-rw-r--r-- | haskell/app/Main.hs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/haskell/app/Main.hs b/haskell/app/Main.hs index e22988c..1b2ccec 100644 --- a/haskell/app/Main.hs +++ b/haskell/app/Main.hs @@ -3,19 +3,34 @@ module Main (main) where import Control.Exception +import System.Environment +import System.Posix.Process import SpaceTraders import SpaceTraders.Automation.Init import SpaceTraders.APIClient.Agent(myAgent) +import SpaceTraders.APIClient.Client +import SpaceTraders.APIClient.Ships import SpaceTraders.APIClient.Systems main :: IO () main = do - config <- initST - ma <- runSpaceTradersT myAgent config - print ma - s <- listSystems (token config) (conn config) + env <- initST + ma <- runSpaceTradersT myAgent env + case ma of + Left (APIResetHappened _) -> do + p <- getExecutablePath + a <- getArgs + e <- getEnvironment + executeFile p False a (Just e) + Left e -> throwIO e + Right ma' -> print ma' + s <- runSpaceTradersT listSystems env case s of Left e -> throwIO e Right s' -> print $ length s' - deinitST config + ships <- runSpaceTradersT listShips env + case ships of + Left e -> throwIO e + Right s' -> print $ s' + deinitST env |