Commit 348fd394 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[BIN] Command line options with help: ~/.local/bin/gargantext --help

parent 5097fc6d
...@@ -9,10 +9,14 @@ Portability : POSIX ...@@ -9,10 +9,14 @@ Portability : POSIX
-} -}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
module Main where module Main where
...@@ -23,27 +27,27 @@ import Data.Text (unpack) ...@@ -23,27 +27,27 @@ import Data.Text (unpack)
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.API (startGargantext, startGargantextMock) 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 { run :: Mode
, port :: Maybe Int
, iniFile :: Maybe Text
}
deriving (Generic, Show)
instance ParseRecord MyOptions
data MyOptions w = MyOptions { run :: w ::: Mode <?> "Possible modes: Dev | Mock | Prod"
, port :: w ::: Maybe Int <?> "By default: 8008"
, iniFile :: w ::: Maybe Text <?> "Example file: gargantext.ini"
}
deriving (Generic)
instance ParseRecord (MyOptions Wrapped)
deriving instance Show (MyOptions Unwrapped)
main :: IO () main :: IO ()
main = do main = do
MyOptions myMode myPort myIniFile <- getRecord
MyOptions myMode myPort myIniFile <- unwrapRecord
"Gargantext: collaborative platform for text-mining" "Gargantext: collaborative platform for text-mining"
let myPort' = case myPort of let myPort' = case myPort of
...@@ -58,7 +62,7 @@ main = do ...@@ -58,7 +62,7 @@ main = do
Nothing -> panic "Need gargantext.ini file" Nothing -> panic "Need gargantext.ini file"
Just i -> i Just i -> i
Mock -> startGargantextMock myPort' Mock -> startGargantextMock myPort'
Dev -> startGargantextMock myPort' _ -> startGargantextMock myPort'
putStrLn $ "Starting Gargantext with mode: " <> show myMode putStrLn $ "Starting Gargantext with mode: " <> show myMode
start start
...@@ -126,11 +126,11 @@ executable: ...@@ -126,11 +126,11 @@ executable:
source-dirs: app source-dirs: app
ghc-options: -threaded -rtsopts -with-rtsopts=-N -O2 ghc-options: -threaded -rtsopts -with-rtsopts=-N -O2
dependencies: dependencies:
- base
- gargantext - gargantext
- ini - ini
- base
- unordered-containers
- optparse-generic - optparse-generic
- unordered-containers
tests: tests:
garg-test: garg-test:
......
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