]> Git — Sourcephile - gargantext.git/blob - bin/gargantext-invitations/Main.hs
Merge remote-tracking branch 'origin/adinapoli/issue-185-job-api' into dev-merge
[gargantext.git] / bin / gargantext-invitations / Main.hs
1 {-|
2 Module : Main.hs
3 Description : GarganText Mailing Invitations
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 Strict #-}
14
15 module Main where
16
17 import Gargantext.API.Dev (withDevEnv, runCmdDev)
18 import Gargantext.API.Node () -- instances only
19 import Gargantext.API.Prelude (GargError)
20 import Gargantext.Core.NLP (HasNLPServer)
21 import Gargantext.Core.Types.Individu (User(..))
22 import Gargantext.Database.Admin.Types.Node
23 import Gargantext.Database.Prelude (CmdRandom)
24 import Gargantext.Prelude
25 import Gargantext.Prelude.Config (readConfig)
26 import Prelude (read)
27 import System.Environment (getArgs)
28 import qualified Gargantext.API.Node.Share as Share
29
30 main :: IO ()
31 main = do
32 params@[iniPath,user,node_id,email] <- getArgs
33
34 _ <- if length params /= 4
35 then panic "USAGE: ./gargantext-init gargantext.ini username node_id student@university.edu"
36 else pure ()
37
38 _cfg <- readConfig iniPath
39
40 let invite :: (CmdRandom env GargError m, HasNLPServer env) => m Int
41 invite = Share.api (UserName $ cs user) (NodeId $ (read node_id :: Int)) (Share.ShareTeamParams $ cs email)
42
43 withDevEnv iniPath $ \env -> do
44 _ <- runCmdDev env invite
45 pure ()