From 5392065ca07ada65acde9b55500ade95e2718079 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexandre=20Delano=C3=AB?= <devel+git@delanoe.org>
Date: Wed, 7 Oct 2020 09:27:15 +0200
Subject: [PATCH] [ADM] binaries to ease new account creations

---
 bin/gargantext-admin/Main.hs   | 33 +++++++++++++++++++++++++++++++++
 bin/gargantext-upgrade/Main.hs |  1 -
 bin/haddock                    |  7 +++++++
 package.yaml                   | 14 ++++++++++++++
 4 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 bin/gargantext-admin/Main.hs
 create mode 100755 bin/haddock

diff --git a/bin/gargantext-admin/Main.hs b/bin/gargantext-admin/Main.hs
new file mode 100644
index 00000000..9010777d
--- /dev/null
+++ b/bin/gargantext-admin/Main.hs
@@ -0,0 +1,33 @@
+{-|
+Module      : Main.hs
+Description : Gargantext Admin tools
+Copyright   : (c) CNRS, 2017-Present
+License     : AGPL + CECILL v3
+Maintainer  : team@gargantext.org
+Stability   : experimental
+Portability : POSIX
+
+
+
+ -}
+
+{-# LANGUAGE Strict            #-}
+
+module Main where
+
+import Gargantext.API.Admin.Settings (withDevEnv, runCmdDev)
+import Gargantext.API.Prelude (GargError)
+import Gargantext.Database.Action.User.New (newUsers)
+import Gargantext.Database.Prelude (Cmd'')
+import Gargantext.Prelude
+import System.Environment (getArgs)
+import Gargantext.API.Admin.Types (DevEnv)
+
+main :: IO ()
+main = do
+  (iniPath:mails) <- getArgs
+
+  withDevEnv iniPath $ \env -> do
+    x <- runCmdDev env ((newUsers $ map cs mails) :: Cmd'' DevEnv GargError Int64)
+    putStrLn $ show x
+  pure ()
diff --git a/bin/gargantext-upgrade/Main.hs b/bin/gargantext-upgrade/Main.hs
index 708477ec..34e75eb0 100644
--- a/bin/gargantext-upgrade/Main.hs
+++ b/bin/gargantext-upgrade/Main.hs
@@ -15,7 +15,6 @@ Import a corpus binary.
 
 module Main where
 
-import Data.Proxy
 import Gargantext.API.Admin.Settings (withDevEnv, runCmdDev)
 import Gargantext.API.Prelude (GargError)
 import Gargantext.API.Node () -- instances only
diff --git a/bin/haddock b/bin/haddock
new file mode 100755
index 00000000..4bd6f239
--- /dev/null
+++ b/bin/haddock
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+#stack haddock --no-haddock-deps --verbose
+
+# if fails, take the command and remove the --hoogle option to get a better message error
+
+/home/alexandre/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.4 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0 haddock --html --hoogle --html-location=../$pkg-$version/ --haddock-option=--hyperlinked-source --haddock-option=--quickjump
diff --git a/package.yaml b/package.yaml
index 8ffe9a21..5b10c16d 100644
--- a/package.yaml
+++ b/package.yaml
@@ -53,6 +53,7 @@ library:
   - Gargantext.Core.Types.Main
   - Gargantext.Core.Utils.Prefix
   - Gargantext.Database.Action.Flow
+  - Gargantext.Database.Action.User.New
   - Gargantext.Database.Query.Table.User
   - Gargantext.Database.Query.Table.Node
   - Gargantext.Database.Query.Table.Node.UpdateOpaleye
@@ -397,6 +398,19 @@ executables:
       - gargantext
       - base
 
+  gargantext-admin:
+    main: Main.hs
+    source-dirs: bin/gargantext-admin
+    ghc-options:
+    - -threaded
+    - -rtsopts
+    - -with-rtsopts=-N
+    - -O2
+    - -Wmissing-signatures
+    dependencies:
+      - gargantext
+      - base
+
   gargantext-cbor2json:
     main: Main.hs
     source-dirs: bin/gargantext-cbor2json
-- 
2.21.0