]> Git — Sourcephile - gargantext.git/blob - app/Main.hs
[APP] command line options added.
[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 {-# LANGUAGE NoImplicitPrelude #-}
13
14 {-# LANGUAGE DeriveGeneric #-}
15 {-# LANGUAGE OverloadedStrings #-}
16
17 module Main where
18
19 import Options.Generic
20 import Data.Text (unpack)
21
22 import Gargantext.Prelude
23 import Gargantext.API (startGargantext, startGargantextMock)
24
25 ------------------------------------------------------
26
27 data Mode = Dev | Mock | Prod
28 deriving (Show, Read, Generic)
29 instance ParseRecord Mode
30 instance ParseField Mode
31 instance ParseFields Mode
32
33 data MyOptions = MyOptions { port :: Maybe Int
34 , iniFile :: Maybe Text
35 , mode :: Maybe Mode
36 }
37 deriving (Generic, Show)
38
39 instance ParseRecord MyOptions
40
41
42
43 main :: IO ()
44 main = do
45 MyOptions myPort myIniFile myMode <- getRecord
46 "Gargantext: collaborative platform for text-mining"
47
48 let myPort' = case myPort of
49 Just p -> p
50 Nothing -> 8008
51
52
53 let start = case myMode of
54 --Nothing -> startGargantext myPort' (unpack myIniFile')
55 Just Prod -> startGargantext myPort' (unpack myIniFile')
56 where
57 myIniFile' = case myIniFile of
58 Nothing -> panic "Need gargantext.ini file"
59 Just i -> i
60 Just Mock -> startGargantextMock myPort'
61 _ -> startGargantextMock myPort'
62
63 start