]> Git — Sourcephile - gargantext.git/blob - app/Main.hs
Merge branch 'pipeline'
[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 {-# LANGUAGE Strict #-}
22
23 module Main where
24
25
26 import Options.Generic
27 import Data.Text (unpack)
28
29 import Gargantext.Prelude
30 import Gargantext.API (startGargantext, startGargantextMock)
31
32 --------------------------------------------------------
33 -- Graph Tests
34 --import qualified Gargantext.Graph.Utils as U
35 --import qualified Gargantext.Graph.Distances.Conditional as C
36 --import qualified Gargantext.Graph.Distances.Distributional as D
37 --import qualified Gargantext.Graph.Distances.Matrice as M
38 --------------------------------------------------------
39
40 data Mode = Dev | Mock | Prod
41 deriving (Show, Read, Generic)
42 instance ParseRecord Mode
43 instance ParseField Mode
44 instance ParseFields Mode
45
46
47 data MyOptions w = MyOptions { run :: w ::: Mode <?> "Possible modes: Dev | Mock | Prod"
48 , port :: w ::: Maybe Int <?> "By default: 8008"
49 , ini :: w ::: Maybe Text <?> "Ini-file path of gargantext.ini"
50 }
51 deriving (Generic)
52
53 instance ParseRecord (MyOptions Wrapped)
54 deriving instance Show (MyOptions Unwrapped)
55
56
57
58 main :: IO ()
59 main = do
60 MyOptions myMode myPort myIniFile <- unwrapRecord
61 "Gargantext: collaborative platform for text-mining"
62
63 let myPort' = case myPort of
64 Just p -> p
65 Nothing -> 8008
66
67 let start = case myMode of
68 --Nothing -> startGargantext myPort' (unpack myIniFile')
69 Prod -> startGargantext myPort' (unpack myIniFile')
70 where
71 myIniFile' = case myIniFile of
72 Nothing -> panic "For Prod mode, you need to fill a gargantext.ini file"
73 Just i -> i
74 Mock -> startGargantextMock myPort'
75 _ -> startGargantextMock myPort'
76
77 putStrLn $ "Starting Gargantext with mode: " <> show myMode
78 start
79
80 -- main' :: IO ()
81 --main' = putStrLn $ show $ M.conditional $ M.myMat 10
82
83