]> Git — Sourcephile - gargantext.git/blob - app/Main.hs
[ADMIN] better message when starting Gargantext in CL.
[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
11
12
13 {-# LANGUAGE DataKinds #-}
14 {-# LANGUAGE DeriveGeneric #-}
15 {-# LANGUAGE FlexibleInstances #-}
16 {-# LANGUAGE OverloadedStrings #-}
17 {-# LANGUAGE StandaloneDeriving #-}
18 {-# LANGUAGE TypeOperators #-}
19
20
21 module Main where
22
23 import Prelude (putStrLn)
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
51 MyOptions myMode myPort myIniFile <- unwrapRecord
52 "Gargantext: collaborative platform for text-mining"
53
54 let myPort' = case myPort of
55 Just p -> p
56 Nothing -> 8008
57
58 let start = case myMode of
59 --Nothing -> startGargantext myPort' (unpack myIniFile')
60 Prod -> startGargantext myPort' (unpack myIniFile')
61 where
62 myIniFile' = case myIniFile of
63 Nothing -> panic "For Prod mode, you need to fill a gargantext.ini file"
64 Just i -> i
65 Mock -> startGargantextMock myPort'
66 _ -> startGargantextMock myPort'
67
68 putStrLn $ "Starting Gargantext with mode: " <> show myMode
69 start