#!/usr/bin/env perl
use
5.014;
use
open
qw(:std :utf8)
;
sub
get_repos_liked_by_user {
my
(
$github_login
) =
@_
;
my
@repos
;
while
(
$url
) {
my
$response
= HTTP::Tiny->new->get(
$url
);
if
(
$response
->{headers}->{
link
} =~ /<(.*?)>; rel=
"next"
/ ) {
$url
= $1;
}
else
{
$url
=
undef
;
}
my
$json
=
$response
->{content};
my
$data
= decode_json(
$json
);
foreach
my
$d
(@{
$data
}) {
push
@repos
, {
name
=>
lc
(
$d
->{name}),
url
=>
$d
->{clone_url},
language
=>
lc
(
$d
->{language} //
'unknown'
),
};
}
}
return
@repos
;
}
sub
main {
my
$github_login
=
$ARGV
[0];
if
(not
defined
$github_login
) {
say
"You should run it as `$0 GITHUB_LOGIN`"
;
exit
1;
}
my
@repos
= get_repos_liked_by_user(
$github_login
);
say
'namespace,name,source'
;
foreach
my
$r
(
@repos
) {
my
$language
=
$r
->{language};
say
$language
.
','
.
$r
->{name} .
','
.
$r
->{url}
;
}
}
main();