]> Git — Sourcephile - gargantext.git/blob - app/Main.hs
[COMMAND LINe] improve optiosn to run at startup.
[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 Prelude (putStrLn)
20
21 import Options.Generic
22 import Data.Text (unpack)
23
24 import Gargantext.Prelude
25 import Gargantext.API (startGargantext, startGargantextMock)
26
27 ------------------------------------------------------
28
29 data Mode = Dev | Mock | Prod
30 deriving (Show, Read, Generic)
31 instance ParseRecord Mode
32 instance ParseField Mode
33 instance ParseFields Mode
34
35 data MyOptions = MyOptions { run :: Mode
36 , port :: Maybe Int
37 , iniFile :: Maybe Text
38 }
39 deriving (Generic, Show)
40
41 instance ParseRecord MyOptions
42
43
44 main :: IO ()
45 main = do
46 MyOptions myMode myPort myIniFile <- getRecord
47 "Gargantext: collaborative platform for text-mining"
48
49 let myPort' = case myPort of
50 Just p -> p
51 Nothing -> 8008
52
53 let start = case myMode of
54 --Nothing -> startGargantext myPort' (unpack myIniFile')
55 Prod -> startGargantext myPort' (unpack myIniFile')
56 where
57 myIniFile' = case myIniFile of
58 Nothing -> panic "Need gargantext.ini file"
59 Just i -> i
60 Mock -> startGargantextMock myPort'
61 Dev -> startGargantextMock myPort'
62
63 putStrLn $ "Starting Gargantext with mode: " <> show myMode
64 start