]> Git — Sourcephile - gargantext.git/blob - bin/gargantext-client/Main.hs
[FEAT] Score Column
[gargantext.git] / bin / gargantext-client / Main.hs
1 module Main where
2
3 import Control.Monad
4 import Network.HTTP.Client
5 import Options
6 import Options.Generic
7 import Prelude
8 import Script (script)
9 import Servant.Client
10
11 main :: IO ()
12 main = do
13 -- we parse CLI options
14 opts@(ClientOpts (Helpful uri) _ _ (Helpful verb)) <- getRecord "Gargantext client"
15 mgr <- newManager defaultManagerSettings
16 burl <- parseBaseUrl uri
17 when verb $ do
18 putStrLn $ "[Debug] user: " ++ maybe "<none>" show (unHelpful $ user opts)
19 putStrLn $ "[Debug] backend: " ++ show burl
20 -- we run 'script' from the Script module, reporting potential errors
21 res <- runClientM (script opts) (mkClientEnv mgr burl)
22 case res of
23 Left err -> putStrLn $ "[Client error] " ++ show err
24 Right a -> print a