-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE NoImplicitPrelude #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE StandaloneDeriving #-}
-{-# LANGUAGE TypeOperators #-}
-{-# LANGUAGE Strict #-}
+{-# LANGUAGE StandaloneDeriving #-}
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE Strict #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
module Main where
-
-import Options.Generic
+import Data.Version (showVersion)
import Data.Text (unpack)
+import qualified Paths_gargantext as PG -- cabal magic build module
+import Options.Generic
+import System.Exit (exitSuccess)
import Gargantext.Prelude
-import Gargantext.API (startGargantext) -- , startGargantextMock)
+import Gargantext.API (startGargantext, Mode(..)) -- , startGargantextMock)
--------------------------------------------------------
-- Graph Tests
--import qualified Gargantext.Graph.Distances.Matrice as M
--------------------------------------------------------
-data Mode = Dev | Mock | Prod
- deriving (Show, Read, Generic)
instance ParseRecord Mode
instance ParseField Mode
instance ParseFields Mode
-
data MyOptions w =
MyOptions { run :: w ::: Mode
<?> "Possible modes: Dev | Mock | Prod"
<?> "By default: 8008"
, ini :: w ::: Maybe Text
<?> "Ini-file path of gargantext.ini"
+ , version :: w ::: Bool
+ <?> "Show version number and exit"
}
deriving (Generic)
main :: IO ()
main = do
- MyOptions myMode myPort myIniFile <- unwrapRecord
+ MyOptions myMode myPort myIniFile myVersion <- unwrapRecord
"Gargantext server"
+ if myVersion then do
+ putStrLn $ "Version: " <> showVersion PG.version
+ System.Exit.exitSuccess
+ else
+ return ()
+
let myPort' = case myPort of
Just p -> p
Nothing -> 8008
let start = case myMode of
- Prod -> startGargantext myPort' (unpack myIniFile')
+ Mock -> panic "[ERROR] Mock mode unsupported"
+ _ -> startGargantext myMode myPort' (unpack myIniFile')
where
myIniFile' = case myIniFile of
Nothing -> panic "[ERROR] gargantext.ini needed"
Just i -> i
- Dev -> panic "[ERROR] Dev mode unsupported"
- Mock -> panic "[ERROR] Mock mode unsupported"
- -- _ -> startGargantextMock myPort'
putStrLn $ "Starting with " <> show myMode <> " mode."
start
-