blib/lib/App/gh/Command/List.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 51 CC 3 SCAR 16.7
CC
3
Cov
0%
run
12.0
options
2.0
BEGIN
2.0
CRAP 5.3
1 package App::gh::Command::List;
2 use warnings;
3 use strict;
4 use base qw(App::gh::Command);
5 use App::gh;
6 use App::gh::Utils;
7  
8  
9 =head1 NAME
10  
11 App::gh::Command::List - list repository from one.
12  
13 =head1 USAGE
14  
15 $ gh list [user id]
16  
17 =cut
18  
19 sub options {
20 ( 'n|name' => 'name_only' )
21 }
22  
23 sub run {
24 my ( $self, $acc ) = @_;
25  
26 $acc ||= App::gh->config->github_id;
27 $acc =~ s{/$}{};
28  
29 # TODO: use api class.
30 my $query = App::gh->github->repos;
31 my @repolist = $query->list_user($acc);
32 push @repolist, $query->next_page while $query->has_next_page;
33  
34 my @lines = ();
35 for my $repo ( @repolist ) {
36 my $repo_name = $repo->{name};
37  
38 # name-only
39 if( $self->{name_only} ) {
40 print $acc . "/" . $repo->{name} , "\n";
41 }
42 else {
43 push @lines , [
44 $acc . "/" . $repo->{name} ,
45 ($repo->{description}||"")
46 ];
47 }
48 }
49 print_list @lines if @lines;
50 }
51  
52 1;
53