]> Git — Sourcephile - gargantext.git/blob - bin/gargantext-import/Main.hs
DevEnv: revamp newDevEnv, rumCmdDev
[gargantext.git] / bin / gargantext-import / Main.hs
1 {-|
2 Module : Main.hs
3 Description : Gargantext Import Corpus
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Import a corpus binary.
11
12 -}
13
14 {-# LANGUAGE NoImplicitPrelude #-}
15 {-# LANGUAGE OverloadedStrings #-}
16 {-# LANGUAGE FlexibleContexts #-}
17 {-# LANGUAGE RankNTypes #-}
18 {-# LANGUAGE Strict #-}
19
20 module Main where
21
22 import Servant (ServantErr)
23 import Gargantext.Prelude
24 import Gargantext.Database.Flow (FlowCmdM, flowCorpus)
25 import Gargantext.Text.Parsers (FileFormat(CsvHalFormat))
26 import Gargantext.Database.Utils (Cmd, connectGargandb, runCmdDev)
27 import Gargantext.Database.Types.Node (CorpusId)
28 --import Gargantext.Database.Schema.User (insertUsers, gargantuaUser, simpleUser)
29 import Gargantext.API.Node () -- instances
30 import Gargantext.API.Settings (newDevEnvWith, DevEnv)
31 import System.Environment (getArgs)
32
33 main :: IO ()
34 main = do
35 [iniPath, name, corpusPath] <- getArgs
36
37 env <- newDevEnvWith iniPath
38
39 {-let createUsers :: Cmd ServantErr Int64
40 createUsers = insertUsers [gargantuaUser,simpleUser]
41 _ <- runCmdDev env createUsers
42 -}
43
44 let cmd :: FlowCmdM DevEnv ServantErr m => m CorpusId
45 cmd = flowCorpus CsvHalFormat corpusPath (cs name)
46 r <- runCmdDev env cmd
47 pure ()
48
49