3 Description : Gargantext starter
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
13 {-# LANGUAGE DataKinds #-}
14 {-# LANGUAGE DeriveGeneric #-}
15 {-# LANGUAGE FlexibleInstances #-}
16 {-# LANGUAGE OverloadedStrings #-}
17 {-# LANGUAGE StandaloneDeriving #-}
18 {-# LANGUAGE TypeOperators #-}
23 import Prelude (putStrLn)
25 import Options.Generic
26 import Data.Text (unpack)
28 import Gargantext.Prelude
29 import Gargantext.API (startGargantext, startGargantextMock)
30 --------------------------------------------------------
32 data Mode = Dev | Mock | Prod
33 deriving (Show, Read, Generic)
34 instance ParseRecord Mode
35 instance ParseField Mode
36 instance ParseFields Mode
39 data MyOptions w = MyOptions { run :: w ::: Mode <?> "Possible modes: Dev | Mock | Prod"
40 , port :: w ::: Maybe Int <?> "By default: 8008"
41 , ini :: w ::: Maybe Text <?> "Ini-file path of gargantext.ini"
45 instance ParseRecord (MyOptions Wrapped)
46 deriving instance Show (MyOptions Unwrapped)
51 MyOptions myMode myPort myIniFile <- unwrapRecord
52 "Gargantext: collaborative platform for text-mining"
54 let myPort' = case myPort of
58 let start = case myMode of
59 --Nothing -> startGargantext myPort' (unpack myIniFile')
60 Prod -> startGargantext myPort' (unpack myIniFile')
62 myIniFile' = case myIniFile of
63 Nothing -> panic "For Prod mode, you need to fill a gargantext.ini file"
65 Mock -> startGargantextMock myPort'
66 _ -> startGargantextMock myPort'
68 putStrLn $ "Starting Gargantext with mode: " <> show myMode