Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
haskell-gargantext
Commits
d765ec00
Commit
d765ec00
authored
Jun 27, 2024
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port `gargantext-admin` into `gargantext-cli`
parent
a8ad31d0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
51 deletions
+55
-51
Main.hs
bin/gargantext-admin/Main.hs
+0
-34
Admin.hs
bin/gargantext-cli/CLI/Admin.hs
+43
-0
Types.hs
bin/gargantext-cli/CLI/Types.hs
+5
-0
Main.hs
bin/gargantext-cli/Main.hs
+6
-2
gargantext.cabal
gargantext.cabal
+1
-15
No files found.
bin/gargantext-admin/Main.hs
deleted
100644 → 0
View file @
a8ad31d0
{-|
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.Dev
(
withDevEnv
,
runCmdDev
)
import
Gargantext.API.Errors.Types
import
Gargantext.Database.Action.User.New
(
newUsers
)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
(
Cmd
''
)
import
Gargantext.Prelude
import
Gargantext.API.Admin.EnvTypes
(
DevEnv
)
import
qualified
Data.List.NonEmpty
as
NE
main
::
IO
()
main
=
do
(
iniPath
:
mails
)
<-
getArgs
withDevEnv
iniPath
$
\
env
->
do
x
<-
runCmdDev
env
((
newUsers
$
NE
.
map
cs
(
NE
.
fromList
mails
))
::
Cmd''
DevEnv
BackendInternalError
(
NonEmpty
UserId
))
putStrLn
(
show
x
::
Text
)
pure
()
bin/gargantext-cli/CLI/Admin.hs
0 → 100644
View file @
d765ec00
module
CLI.Admin
(
adminCLI
,
adminCmd
)
where
import
CLI.Types
import
Data.List.NonEmpty
qualified
as
NE
import
Data.Text
qualified
as
T
import
Gargantext.API.Admin.EnvTypes
import
Gargantext.API.Dev
import
Gargantext.API.Errors
import
Gargantext.Core.Types
import
Gargantext.Database.Action.User.New
import
Gargantext.Database.Prelude
import
Gargantext.Prelude
import
Options.Applicative
import
Prelude
(
String
)
adminCLI
::
AdminArgs
->
IO
()
adminCLI
(
AdminArgs
iniPath
mails
)
=
do
withDevEnv
iniPath
$
\
env
->
do
x
<-
runCmdDev
env
((
newUsers
$
NE
.
map
cs
(
NE
.
fromList
mails
))
::
Cmd''
DevEnv
BackendInternalError
(
NonEmpty
UserId
))
putStrLn
(
show
x
::
Text
)
adminCmd
::
HasCallStack
=>
Mod
CommandFields
CLI
adminCmd
=
command
"admin"
(
info
(
helper
<*>
fmap
CLISub
admin_p
)
(
progDesc
"Create users."
))
admin_p
::
Parser
CLICmd
admin_p
=
fmap
CCMD_admin
$
AdminArgs
<$>
(
strOption
(
long
"ini-path"
<>
metavar
"FILEPATH"
<>
help
"Location of the .ini path"
)
)
<*>
(
option
(
maybeReader
emails_p
)
(
long
"emails"
<>
metavar
"email1,email2,..."
<>
help
"A comma-separated list of emails."
)
)
emails_p
::
String
->
Maybe
[
String
]
emails_p
s
=
case
T
.
splitOn
","
(
T
.
pack
s
)
of
[]
->
Nothing
xs
->
pure
$
map
T
.
unpack
xs
bin/gargantext-cli/CLI/Types.hs
View file @
d765ec00
...
...
@@ -22,11 +22,16 @@ data ObfuscateDBArgs = ObfuscateDBArgs {
,
dbPassword
::
!
Text
}
deriving
(
Show
,
Eq
)
data
AdminArgs
=
AdminArgs
{
iniPath
::
!
FilePath
,
emails
::
[
String
]
}
deriving
(
Show
,
Eq
)
data
CLICmd
=
CCMD_clean_csv_corpus
|
CCMD_filter_terms_and_cooc
!
CorpusFile
!
TermListFile
!
OutputFile
|
CCMD_obfuscate_db
!
ObfuscateDBArgs
|
CCMD_admin
!
AdminArgs
deriving
(
Show
,
Eq
)
data
CLI
=
...
...
bin/gargantext-cli/Main.hs
View file @
d765ec00
...
...
@@ -23,6 +23,7 @@ import CLI.FilterTermsAndCooc
import
CLI.ObfuscateDB
(
obfuscateDB
,
obfuscateDBCmd
)
import
CLI.Types
import
Options.Applicative
import
CLI.Admin
(
adminCLI
,
adminCmd
)
runCLI
::
CLI
->
IO
()
runCLI
=
\
case
...
...
@@ -32,17 +33,20 @@ runCLI = \case
->
filterTermsAndCoocCLI
corpusFile
termListFile
outputFile
CLISub
(
CCMD_obfuscate_db
args
)
->
obfuscateDB
args
CLISub
(
CCMD_admin
args
)
->
adminCLI
args
main
::
IO
()
main
=
runCLI
=<<
execParser
opts
where
opts
=
info
(
helper
<*>
allOptions
)
(
fullDesc
<>
progDesc
"CLI for the gargantext-server"
<>
progDesc
"CLI for the gargantext-server
. Type --help for all the commands.
"
<>
header
"gargantext-cli tools"
)
allOptions
::
Parser
CLI
allOptions
=
subparser
(
filterTermsAndCoocCmd
<>
obfuscateDBCmd
obfuscateDBCmd
<>
adminCmd
)
gargantext.cabal
View file @
d765ec00
...
...
@@ -692,27 +692,13 @@ library
, zip-archive ^>= 0.4.3
, zlib ^>= 0.6.2.3
executable gargantext-admin
import:
defaults
, optimized
main-is: Main.hs
other-modules:
Paths_gargantext
hs-source-dirs:
bin/gargantext-admin
build-depends:
extra
, gargantext
, gargantext-prelude
, text
executable gargantext-cli
import:
defaults
, optimized
main-is: Main.hs
other-modules:
CLI.Admin
CLI.CleanCsvCorpus
CLI.FilterTermsAndCooc
CLI.ObfuscateDB
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment