Commit 761dcb39 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[COMMAND LINe] improve optiosn to run at startup.

parent 1f7c0768
...@@ -16,6 +16,8 @@ Portability : POSIX ...@@ -16,6 +16,8 @@ Portability : POSIX
module Main where module Main where
import Prelude (putStrLn)
import Options.Generic import Options.Generic
import Data.Text (unpack) import Data.Text (unpack)
...@@ -27,37 +29,36 @@ import Gargantext.API (startGargantext, startGargantextMock) ...@@ -27,37 +29,36 @@ import Gargantext.API (startGargantext, startGargantextMock)
data Mode = Dev | Mock | Prod data Mode = Dev | Mock | Prod
deriving (Show, Read, Generic) deriving (Show, Read, Generic)
instance ParseRecord Mode instance ParseRecord Mode
instance ParseField Mode instance ParseField Mode
instance ParseFields Mode instance ParseFields Mode
data MyOptions = MyOptions { port :: Maybe Int data MyOptions = MyOptions { run :: Mode
, port :: Maybe Int
, iniFile :: Maybe Text , iniFile :: Maybe Text
, mode :: Maybe Mode }
}
deriving (Generic, Show) deriving (Generic, Show)
instance ParseRecord MyOptions instance ParseRecord MyOptions
main :: IO () main :: IO ()
main = do main = do
MyOptions myPort myIniFile myMode <- getRecord MyOptions myMode myPort myIniFile <- getRecord
"Gargantext: collaborative platform for text-mining" "Gargantext: collaborative platform for text-mining"
let myPort' = case myPort of let myPort' = case myPort of
Just p -> p Just p -> p
Nothing -> 8008 Nothing -> 8008
let start = case myMode of let start = case myMode of
--Nothing -> startGargantext myPort' (unpack myIniFile') --Nothing -> startGargantext myPort' (unpack myIniFile')
Just Prod -> startGargantext myPort' (unpack myIniFile') Prod -> startGargantext myPort' (unpack myIniFile')
where where
myIniFile' = case myIniFile of myIniFile' = case myIniFile of
Nothing -> panic "Need gargantext.ini file" Nothing -> panic "Need gargantext.ini file"
Just i -> i Just i -> i
Just Mock -> startGargantextMock myPort' Mock -> startGargantextMock myPort'
_ -> startGargantextMock myPort' Dev -> startGargantextMock myPort'
putStrLn $ "Starting Gargantext with mode: " <> show myMode
start start
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment