#!/usr/local/bin/perl -w
###########################################
# repo-list - List high-scoring perl repos
# Mike Schilli, 2015 (m@perlmeister.com)
###########################################
use strict;
use Net::GitHub;
use YAML qw( LoadFile );

my $gh_conf = (glob "~")[0] . "/.githubrc";

my $gh = Net::GitHub->new( access_token => 
  LoadFile( $gh_conf )->{ token }
);

my %data = $gh->search->repositories( {
  q     => 'log4perl',
  sort  => 'stars',
  order => 'desc',
});

my @items = ();
push @items, @{ $data{ items } };

while( $gh->search->has_next_page() ) {
  my %data = $gh->search->next_page();
  push @items, @{ $data{ items } };
}

for my $item ( @items ) {
  printf "%s (%.1f)\n", 
    $item->{ full_name }, 
    $item->{ stargazers_count };
}
