]> Git — Sourcephile - gargantext.git/blob - app/Main.hs
[RENAME/ORG] ngrams -> terms.
[gargantext.git] / app / Main.hs
1 {-|
2 Module : Main.hs
3 Description : Gargantext starter
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Script to start gargantext with different modes (Dev, Prod, Mock).
11
12 -}
13
14 {-# LANGUAGE DataKinds #-}
15 {-# LANGUAGE DeriveGeneric #-}
16 {-# LANGUAGE FlexibleInstances #-}
17 {-# LANGUAGE NoImplicitPrelude #-}
18 {-# LANGUAGE OverloadedStrings #-}
19 {-# LANGUAGE StandaloneDeriving #-}
20 {-# LANGUAGE TypeOperators #-}
21
22 module Main where
23
24
25 import Options.Generic
26 import Data.Text (unpack)
27
28 import Gargantext.Prelude
29 import Gargantext.API (startGargantext, startGargantextMock)
30 --------------------------------------------------------
31
32 data Mode = Dev | Mock | Prod
33 deriving (Show, Read, Generic)
34 instance ParseRecord Mode
35 instance ParseField Mode
36 instance ParseFields Mode
37
38
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"
42 }
43 deriving (Generic)
44
45 instance ParseRecord (MyOptions Wrapped)
46 deriving instance Show (MyOptions Unwrapped)
47
48 main :: IO ()
49 main = do
50 MyOptions myMode myPort myIniFile <- unwrapRecord
51 "Gargantext: collaborative platform for text-mining"
52
53 let myPort' = case myPort of
54 Just p -> p
55 Nothing -> 8008
56
57 let start = case myMode of
58 --Nothing -> startGargantext myPort' (unpack myIniFile')
59 Prod -> startGargantext myPort' (unpack myIniFile')
60 where
61 myIniFile' = case myIniFile of
62 Nothing -> panic "For Prod mode, you need to fill a gargantext.ini file"
63 Just i -> i
64 Mock -> startGargantextMock myPort'
65 _ -> startGargantextMock myPort'
66
67 putStrLn $ "Starting Gargantext with mode: " <> show myMode
68 start