diff options
Diffstat (limited to 'haskell/app')
-rw-r--r-- | haskell/app/Main.hs | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/haskell/app/Main.hs b/haskell/app/Main.hs index 38e6b0d..e22988c 100644 --- a/haskell/app/Main.hs +++ b/haskell/app/Main.hs @@ -3,36 +3,19 @@ module Main (main) where import Control.Exception -import qualified Database.SQLite.Simple as S -import qualified Data.Text as T -import SpaceTraders.APIClient.Agent +import SpaceTraders +import SpaceTraders.Automation.Init +import SpaceTraders.APIClient.Agent(myAgent) import SpaceTraders.APIClient.Systems -import SpaceTraders.Database -import SpaceTraders.Database.Agents -import SpaceTraders.Database.Contracts -import SpaceTraders.Database.Ships -import SpaceTraders.Database.Tokens main :: IO () main = do - conn <- open - t <- getToken conn `catch` registerNow conn - ma <- myAgent t + config <- initST + ma <- runSpaceTradersT myAgent config print ma - s <- listSystems t conn - print s - close conn - where - registerNow :: S.Connection -> SomeException -> IO (T.Text) - registerNow conn _ = do - r <- register "ADYXAX" "COSMIC" - case r of - Right r' -> do - setAgent conn $ agent r' - addContract conn $ contract r' - addShip conn $ ship r' - let t = token r' - setToken conn $ t - return t - Left e' -> throwIO e' + s <- listSystems (token config) (conn config) + case s of + Left e -> throwIO e + Right s' -> print $ length s' + deinitST config |