]> Git — Sourcephile - gargantext.git/blob - app/Main.hs
[BIN] Command line options with help: ~/.local/bin/gargantext --help
[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 , iniFile :: w ::: Maybe Text <?> "Example file: gargantext.ini"
42 }
43 deriving (Generic)
44 instance ParseRecord (MyOptions Wrapped)
45 deriving instance Show (MyOptions Unwrapped)
46
47 main :: IO ()
48 main = do
49
50 MyOptions myMode myPort myIniFile <- unwrapRecord
51 "Gargantext: collaborative platform for text-mining"
52
53 let myPort' = case myPort of
54 Just p -> p
55 Nothing -> 8008
56
57 let start = case myMode of
58 --Nothing -> startGargantext myPort' (unpack myIniFile')
59 Prod -> startGargantext myPort' (unpack myIniFile')
60 where
61 myIniFile' = case myIniFile of
62 Nothing -> panic "Need gargantext.ini file"
63 Just i -> i
64 Mock -> startGargantextMock myPort'
65 _ -> startGargantextMock myPort'
66
67 putStrLn $ "Starting Gargantext with mode: " <> show myMode
68 start