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
409c8423
Commit
409c8423
authored
Jul 01, 2024
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port gargantext-invitations to CLI
parent
5760e558
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
16 deletions
+77
-16
Invitations.hs
bin/gargantext-cli/CLI/Invitations.hs
+62
-0
Types.hs
bin/gargantext-cli/CLI/Types.hs
+9
-0
Main.hs
bin/gargantext-cli/Main.hs
+5
-1
gargantext.cabal
gargantext.cabal
+1
-15
No files found.
bin/gargantext-
invitations/Main
.hs
→
bin/gargantext-
cli/CLI/Invitations
.hs
View file @
409c8423
{-|
Module :
Main
.hs
Module :
Invitations
.hs
Description : GarganText Mailing Invitations
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
...
...
@@ -12,35 +12,51 @@ Portability : POSIX
{-# LANGUAGE Strict #-}
module
Main
where
module
CLI.Invitations
where
import
CLI.Types
import
Gargantext.API.Admin.Types
import
Gargantext.API.Dev
(
withDevEnv
,
runCmdDev
)
import
Gargantext.API.Node
()
-- instances only
import
Gargantext.API.Errors.Types
import
Gargantext.API.Admin.Types
import
Gargantext.API.Node
()
-- instances only
import
Gargantext.API.Node.Share
qualified
as
Share
import
Gargantext.API.Node.Share.Types
qualified
as
Share
import
Gargantext.Core.NLP
(
HasNLPServer
)
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
(
CmdRandom
)
import
Gargantext.Prelude
import
Gargantext.Prelude.Config
(
readConfig
)
import
Prelude
(
read
)
import
Gargantext.API.Node.Share.Types
qualified
as
Share
import
Gargantext.API.Node.Share
qualified
as
Share
main
::
IO
()
main
=
do
params
@
[
iniPath
,
user
,
node_id
,
email
]
<-
getArgs
_
<-
if
length
params
/=
4
then
panicTrace
"USAGE: ./gargantext-init gargantext.ini username node_id student@university.edu"
else
pure
()
import
Options.Applicative
import
Prelude
(
String
)
import
Gargantext.Core.Types
invitationsCLI
::
InvitationsArgs
->
IO
()
invitationsCLI
(
InvitationsArgs
iniPath
user
node_id
email
)
=
do
_cfg
<-
readConfig
iniPath
let
invite
::
(
HasSettings
env
,
CmdRandom
env
BackendInternalError
m
,
HasNLPServer
env
)
=>
m
Int
invite
=
Share
.
api
(
UserName
$
cs
user
)
(
UnsafeMkNodeId
$
(
read
node_id
::
Int
))
(
Share
.
ShareTeamParams
$
cs
email
)
invite
=
Share
.
api
(
UserName
$
cs
user
)
node_id
(
Share
.
ShareTeamParams
$
cs
email
)
withDevEnv
iniPath
$
\
env
->
do
_
<-
runCmdDev
env
invite
pure
()
void
$
runCmdDev
env
invite
invitationsCmd
::
HasCallStack
=>
Mod
CommandFields
CLI
invitationsCmd
=
command
"invitations"
(
info
(
helper
<*>
fmap
CLISub
invitations_p
)
(
progDesc
"Mailing invitations."
))
invitations_p
::
Parser
CLICmd
invitations_p
=
fmap
CCMD_invitations
$
InvitationsArgs
<$>
(
strOption
(
long
"ini-path"
<>
metavar
"FILEPATH"
<>
help
"Location of the .ini path"
)
)
<*>
(
strOption
(
long
"user"
)
)
<*>
(
option
(
eitherReader
node_p
)
(
long
"node-id"
<>
metavar
"POSITIVE-INT"
<>
help
"The node ID."
)
)
<*>
(
strOption
(
long
"email"
<>
help
"The email address."
)
)
node_p
::
String
->
Either
String
NodeId
node_p
i
=
case
readMaybe
i
of
Nothing
->
Left
$
i
<>
" is not a valid integer."
Just
xs
|
xs
<
0
->
Left
$
"The node id needs to be a positive integer."
|
otherwise
->
Right
$
UnsafeMkNodeId
xs
bin/gargantext-cli/CLI/Types.hs
View file @
409c8423
...
...
@@ -5,6 +5,7 @@ import Data.String
import
Data.Text
(
Text
)
import
Gargantext.Core.Types.Query
import
Prelude
import
Gargantext.Core.Types
(
NodeId
)
newtype
CorpusFile
=
CorpusFile
{
_CorpusFile
::
FilePath
}
deriving
(
Show
,
Eq
,
IsString
)
...
...
@@ -47,6 +48,13 @@ data InitArgs = InitArgs
{
init_ini
::
!
FilePath
}
deriving
(
Show
,
Eq
)
data
InvitationsArgs
=
InvitationsArgs
{
inv_path
::
!
FilePath
,
inv_user
::
!
Text
,
inv_node_id
::
!
NodeId
,
inv_email
::
!
Text
}
deriving
(
Show
,
Eq
)
data
CLICmd
=
CCMD_clean_csv_corpus
|
CCMD_filter_terms_and_cooc
!
CorpusFile
!
TermListFile
!
OutputFile
...
...
@@ -54,6 +62,7 @@ data CLICmd
|
CCMD_admin
!
AdminArgs
|
CCMD_import
!
ImportArgs
|
CCMD_init
!
InitArgs
|
CCMD_invitations
!
InvitationsArgs
deriving
(
Show
,
Eq
)
data
CLI
=
...
...
bin/gargantext-cli/Main.hs
View file @
409c8423
...
...
@@ -26,6 +26,7 @@ import Options.Applicative
import
CLI.Admin
(
adminCLI
,
adminCmd
)
import
CLI.Import
(
importCLI
,
importCmd
)
import
CLI.Init
(
initCLI
,
initCmd
)
import
CLI.Invitations
(
invitationsCLI
,
invitationsCmd
)
runCLI
::
CLI
->
IO
()
runCLI
=
\
case
...
...
@@ -41,6 +42,8 @@ runCLI = \case
->
importCLI
args
CLISub
(
CCMD_init
args
)
->
initCLI
args
CLISub
(
CCMD_invitations
args
)
->
invitationsCLI
args
main
::
IO
()
main
=
runCLI
=<<
execParser
opts
...
...
@@ -56,5 +59,6 @@ allOptions = subparser (
obfuscateDBCmd
<>
adminCmd
<>
importCmd
<>
initCmd
initCmd
<>
invitationsCmd
)
gargantext.cabal
View file @
409c8423
...
...
@@ -703,6 +703,7 @@ executable gargantext-cli
CLI.FilterTermsAndCooc
CLI.Import
CLI.Init
CLI.Invitations
CLI.ObfuscateDB
CLI.Types
CLI.Utils
...
...
@@ -729,21 +730,6 @@ executable gargantext-cli
, unordered-containers ^>= 0.2.16.0
, vector ^>= 0.12.3.0
executable gargantext-invitations
import:
defaults
, optimized
main-is: Main.hs
other-modules:
Paths_gargantext
hs-source-dirs:
bin/gargantext-invitations
build-depends:
extra ^>= 1.7.9
, gargantext
, gargantext-prelude
, text ^>= 1.2.4.1
executable gargantext-phylo
import:
defaults
...
...
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