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