FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
github/samples/Search/SearchRepos.hs at master · meowgorithm/github · GitHub
meowgorithm
/
github
Public
forked from
haskell-github/github
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
github
/
samples
/
Search
/
SearchRepos.hs
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (51 loc) · 2 KB
Breadcrumbs
github
/
samples
/
Search
/
SearchRepos.hs
Copy path
File metadata and controls
56 lines (51 loc) · 2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{-#
LANGUAGE
OverloadedStrings #-}
module
SearchRepos
where
import
qualified
Github.Search
as
Github
import
qualified
Github.Data
as
Github
import
Control.Monad
(
forM
,
forM_
)
import
Data.Maybe
(
fromMaybe
)
import
Data.List
(
intercalate
)
import
System.Environment
(
getArgs
)
import
Text.Printf
(
printf
)
import
Data.Time.Clock
(
getCurrentTime
,
UTCTime
(
..
))
import
Data.Time.LocalTime
(
utc
,
utcToLocalTime
,
localDay
,
localTimeOfDay
,
TimeOfDay
(
..
))
import
Data.Time.Calendar
(
toGregorian
)
main
=
do
args
<-
getArgs
date
<-
case
args
of
(x
:
_)
->
return
x
otherwise
->
today
let
query
=
"
q=language%3Ahaskell created%3A>
"
++
date
++
"
&per_page=100
"
let
auth
=
Nothing
result
<-
Github.
searchRepos' auth query
case
result
of
Left
e
->
putStrLn
$
"
Error:
"
++
show
e
Right
r
->
do
forM_ (
Github.
searchReposRepos r) (
\
r
->
do
putStrLn
$
formatRepo r
putStrLn
"
"
)
putStrLn
$
"
Count:
"
++
show
n
++
"
Haskell repos created since
"
++
date
where
n
=
Github.
searchReposTotalCount r
--
|
return today (in UTC) formatted as YYYY-MM-DD
today
::
IO
String
today
=
do
now
<-
getCurrentTime
let
day
=
localDay
$
utcToLocalTime utc now
(y,m,d)
=
toGregorian day
in
return
$
printf
"
%d-%02d-%02d
"
y m d
formatRepo
::
Github.
Repo
->
String
formatRepo r
=
let
fields
=
[ (
"
Name
"
,
Github.
repoName)
,(
"
URL
"
,
Github.
repoHtmlUrl)
,(
"
Description
"
, orEmpty
.
Github.
repoDescription)
,(
"
Created-At
"
, formatMaybeDate
.
Github.
repoCreatedAt)
,(
"
Pushed-At
"
, formatMaybeDate
.
Github.
repoPushedAt)
,(
"
Stars
"
,
show
.
Github.
repoStargazersCount)
]
in
intercalate
"
\n
"
$
map
fmt fields
where
fmt (s,f)
=
fill
12
(s
++
"
:
"
)
++
"
"
++
f r
orEmpty
=
fromMaybe
"
"
fill n s
=
s
++
replicate
n'
'
'
where
n'
=
max
0
(n
-
length
s)
formatMaybeDate
=
maybe
"
???
"
formatDate
formatDate
=
show
.
Github.
fromDate
Back
|
FazBrowse Home
|
New Git URL