Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
gargantext
crawlers
hal
Commits
8f47d29c
Commit
8f47d29c
authored
Dec 21, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[main] add optparse for command line parsing
parent
63e6bb6c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
12 deletions
+44
-12
Main.hs
app/Main.hs
+38
-10
crawlerHAL.cabal
crawlerHAL.cabal
+5
-2
package.yaml
package.yaml
+1
-0
No files found.
app/Main.hs
View file @
8f47d29c
...
...
@@ -6,6 +6,7 @@ module Main where
import
NeatInterpolation
(
text
)
import
Network.HTTP.Client
(
newManager
)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Options.Applicative
import
Servant.Client
import
HAL
(
getMetadataWith
)
...
...
@@ -16,14 +17,34 @@ import Tree
import
qualified
Data.Text
as
T
data
CountParams
=
CountParams
{
cp_query
::
T
.
Text
}
data
Command
=
Count
CountParams
countParams
::
Parser
Command
countParams
=
Count
<$>
(
CountParams
<$>
strArgument
(
metavar
"query"
))
params
::
Parser
Command
params
=
subparser
(
command
"count"
(
info
countParams
(
progDesc
"Count number of docs for a given query"
)))
opts
::
ParserInfo
Command
opts
=
info
(
params
<**>
helper
)
(
fullDesc
<>
progDesc
"A program to test HAL"
<>
header
"crawlerHAL-exe"
)
yearReq
=
[
text
|
(language_t:en)
AND (producedDateY_i:2015
OR producedDateY_i:2016
OR producedDateY_i:2017
OR producedDateY_i:2018
(language_t:en)
AND (producedDateY_i:2015
OR producedDateY_i:2016
OR producedDateY_i:2017
OR producedDateY_i:2018
OR producedDateY_i:2021
OR producedDateY_i:2022)
OR producedDateY_i:2022)
AND (structId_i:302102
OR structId_i:469216
OR structId_i:6279
...
...
@@ -63,8 +84,15 @@ imt = [
]
main
::
IO
()
main
=
do
res
<-
getMetadataWith
(
generateRequestByStructID
"artificial intelligence"
imt
)
(
Just
0
)
(
Just
55
)
main
=
run
=<<
execParser
opts
-- res <- getMetadataWith (generateRequestByStructID "artificial intelligence" imt) (Just 0) (Just 55)
-- case res of
-- (Left err) -> print err
-- (Right val) -> print $ _docs val
run
::
Command
->
IO
()
run
(
Count
(
CountParams
{
cp_query
}))
=
do
res
<-
getMetadataWithC
(
cp_query
)
(
Just
0
)
Nothing
case
res
of
(
Left
err
)
->
print
err
(
Right
val
)
->
print
$
_docs
val
Left
err
->
print
err
Right
(
cnt
,
_docsC
)
->
print
$
show
cnt
crawlerHAL.cabal
View file @
8f47d29c
cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.3
4.4
.
-- This file has been generated from package.yaml by hpack version 0.3
5.0
.
--
-- see: https://github.com/sol/hpack
--
-- hash:
5e660f75d650f1d72f17df082838eb0dc3d6bdd2f514b9931a97ddc17a47b5c0
-- hash:
d5f6b9788433a3873efd55684dfd55f4d85380f24209a6a8eb8ba80c82a330f8
name: crawlerHAL
version: 0.1.0.0
...
...
@@ -54,6 +54,7 @@ library
, http-client-tls
, lens
, neat-interpolation
, optparse-applicative
, scientific
, servant
, servant-client
...
...
@@ -89,6 +90,7 @@ executable crawlerHAL-exe
, http-client-tls
, lens
, neat-interpolation
, optparse-applicative
, scientific
, servant
, servant-client
...
...
@@ -125,6 +127,7 @@ test-suite halCrawler-test
, http-client-tls
, lens
, neat-interpolation
, optparse-applicative
, scientific
, servant
, servant-client
...
...
package.yaml
View file @
8f47d29c
...
...
@@ -30,6 +30,7 @@ dependencies:
-
http-client-tls
-
lens
-
neat-interpolation
-
optparse-applicative
-
scientific
-
servant
-
servant-client
...
...
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