]> Git — Sourcephile - gargantext.git/blob - bin/gargantext-import/Main.hs
[FIX] repo file snapshots.
[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 Control.Exception (finally)
23 import Servant (ServantErr)
24 import Gargantext.Prelude
25 import Gargantext.Database.Flow (FlowCmdM, flowCorpus)
26 import Gargantext.Text.Parsers (FileFormat(CsvHalFormat))
27 import Gargantext.Database.Utils (Cmd, )
28 import Gargantext.Database.Types.Node (CorpusId)
29 --import Gargantext.Database.Schema.User (insertUsers, gargantuaUser, simpleUser)
30 import Gargantext.API.Node () -- instances
31 import Gargantext.API.Settings (newDevEnvWith, runCmdDev, DevEnv)
32 import System.Environment (getArgs)
33
34 main :: IO ()
35 main = do
36 [iniPath, name, corpusPath] <- getArgs
37
38 {-let createUsers :: Cmd ServantErr Int64
39 createUsers = insertUsers [gargantuaUser,simpleUser]
40 -}
41
42 let cmdCorpus :: forall m. FlowCmdM DevEnv ServantErr m => m CorpusId
43 cmdCorpus = flowCorpus CsvHalFormat corpusPath (cs name)
44
45 -- cmd = {-createUsers >>-} cmdCorpus
46
47 env <- newDevEnvWith iniPath
48 -- Better if we keep only one call to runCmdDev.
49 _ <- runCmdDev env cmdCorpus
50 pure ()
51
52