| 1 | package App::GitHub; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # ABSTRACT: GitHub Command Tools | ||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Net::GitHub; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Term::ReadKey; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Term::ReadLine; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use JSON::XS; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use IPC::Cmd qw/can_run/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | our $VERSION = '1.0.1'; | |||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | has 'term' => ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | default => sub { Term::ReadLine->new('Perl-App-GitHub') } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | has 'prompt' => ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | default => sub { 'github> ' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | has 'out_fh' => ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | shift->term->OUT || \*STDOUT; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | has 'repo_regexp' => ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | isa => 'RegexpRef', | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | default => sub { qr/^([\-\w]+)[\/\\\s]([\-\w]+)$/ } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # For non-interactive mode | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | has 'silent' => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub print_err { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_err: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | shift->print( @_, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub print { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=10 SCAR=41.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my ( $self, $message, $error ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | return 1 if $self->silent and not $error; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->silent and not $error
MC/DC0%0/2
$self->silent and not $error
$self->silent
not $error
Truth table0%0/3
A and not(B)
A= $self->silentB= not $error
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $rows = ( GetTerminalSize( $self->out_fh ) )[1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $message_rows = $message =~ tr/\n/\n/; | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $pager_use = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # let less exit if one screen | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | local $ENV{LESS} ||= ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
local $ENV{"LESS"} ||= ""
MC/DC0%0/1
local $ENV{"LESS"} ||= ""
local $ENV{"LESS"}
Truth table0%0/2
A
A= local $ENV{"LESS"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $ENV{LESS} .= " -F"; | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ( $@ or $message_rows < $rows ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ or $message_rows < $rows
MC/DC0%0/2
$@ or $message_rows < $rows
$@
$message_rows < $rows
Truth table0%0/3
A or B
A= $@B= $message_rows < $rows
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | chomp $message; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $message .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $fh = $self->out_fh; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | open $fh, '|-', $self->_get_pager | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
open($fh, '|-', $self->_get_pager) || croak("unable to open more: $!")
MC/DC0%0/1
open($fh, '|-', $self->_get_pager) || croak("unable to open more: $!")
open($fh, '|-', $self->_get_pager)
Truth table0%0/2
A
A= open($fh, '|-', $self->_get_pager)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | or croak "unable to open more: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | or $fh = $self->out_fh; | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $pager_use = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | print $fh "$message"; | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | print $fh "\n" if $self->term->ReadLine =~ /Gnu/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | close($fh) if $pager_use; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub _get_pager { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_pager: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | my $pager = | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | $ENV{PAGER} | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | || can_run("less") | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$ENV{'PAGER'} || can_run('less') || can_run('more') || croak('no pager found')
$ENV{"PAGER"} or can_run("less") or can_run("more")
$ENV{"PAGER"} or can_run("less")
MC/DC0%0/3
$ENV{'PAGER'} || can_run('less') || can_run('more') || croak('no pager found')
$ENV{"PAGER"}
can_run("less")
can_run("more")
Truth table0%0/4
A or B or C
A= $ENV{"PAGER"}B= can_run("less")C= can_run("more")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | || can_run("more") | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | || croak "no pager found"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | sub read { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my ( $self, $prompt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $prompt ||= $self->prompt; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$prompt ||= $self->prompt
MC/DC0%0/2
$prompt ||= $self->prompt
$prompt
$self->prompt
Truth table0%0/3
A ||= B
A= $promptB= $self->prompt
| |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return $self->term->readline($prompt); | |||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | has 'github' => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | isa => 'Net::GitHub', | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | has '_data' => ( is => 'rw', isa => 'HashRef', default => sub { {} } ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | my $dispatch = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | 'exit' => sub { exit; }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | 'quit' => sub { exit; }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | 'q' => sub { exit; }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | '?' => \&help, | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 'h' => \&help, | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # Common | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | repo => \&set_repo, | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | login => \&set_login, | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | loadcfg => \&set_loadcfg, | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # Repo | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | 'r.show' => sub { shift->run_basic_repo_cmd( 'repos', 'get', shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 'r.list' => \&repo_list, | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | 'r.watch' => sub { shift->run_basic_repo_cmd( 'repos', 'watch', shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 'r.unwatch' => | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub { shift->run_basic_repo_cmd( 'repos', 'unwatch', shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 'r.fork' => | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub { shift->run_basic_repo_cmd( 'repos', 'create_fork', shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 'r.create' => \&repo_create, | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | 'r.set_private' => sub { shift->repo_update( private => \1, shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | 'r.set_public' => sub { shift->repo_update( private => \0, shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # XXX? TODO, deploy_keys collaborators | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 'r.commit' => | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub { shift->run_github_with_repo( 'git_data', 'commit', shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # Issues | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | 'i.list' => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my ( $self, $type ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $type ||= 'open'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$type ||= "open"
MC/DC0%0/1
$type ||= "open"
$type
Truth table0%0/2
A
A= $type
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $self->run_github_with_repo( 'issue', 'repos_issues', | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | { state => $type } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | 'i.view' => sub { shift->run_github_with_repo( 'issue', 'issue', shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | 'i.open' => sub { shift->issue_open_or_edit('open') }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | 'i.edit' => sub { shift->issue_open_or_edit( 'edit', @_ ) }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | 'i.close' => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | shift->run_github_with_repo( 'issue', 'update_issue', shift, | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | { state => 'closed' } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | 'i.reopen' => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | shift->run_github_with_repo( 'issue', 'update_issue', shift, | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | { state => 'open' } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 'i.label' => \&issue_label, | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 'i.comment' => \&issue_comment, | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # User | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | 'u.show' => sub { shift->run_github( 'user', 'show', shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 'u.update' => \&user_update, | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | 'u.followers' => sub { shift->run_github( 'user', 'followers' ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | 'u.following' => sub { shift->run_github( 'user', 'following' ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | 'u.follow' => sub { shift->run_github( 'user', 'follow', shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | 'u.unfollow' => sub { shift->run_github( 'user', 'unfollow', shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | 'u.pub_keys' => sub { shift->user_pub_keys('show'); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | 'u.pub_keys.add' => sub { shift->user_pub_keys( 'add', @_ ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | 'u.pub_keys.del' => sub { shift->user_pub_keys( 'del', @_ ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # Object | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 'o.tree' => | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub { shift->run_github_with_repo( 'git_data', 'tree', shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 'o.trees' => | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sub { shift->run_github_with_repo( 'git_data', 'tree', shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 'o.blob' => | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub { shift->run_github_with_repo( 'git_data', 'blob', shift ); }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $self->print(<<START); | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | Welcome to GitHub Command Tools! (Ver: $VERSION) | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | Type '?' or 'h' for help. | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | START | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $self->set_loadcfg(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | while ( defined( my $command = $self->read ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $command =~ s/(^\s+|\s+$)//g; | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | next unless length($command); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # check dispatch | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if ( exists $dispatch->{$command} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $dispatch->{$command}->($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # split the command out | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ( $command, my $args ) = split( /\s+/, $command, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ( $command and exists $dispatch->{$command} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$command and exists $dispatch->{$command}
MC/DC0%0/2
$command and exists $dispatch->{$command}
$command
exists $dispatch->{$command}
Truth table0%0/3
A and B
A= $commandB= exists $dispatch->{$command}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $dispatch->{$command}->( $self, $args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $self->print("Unknown command, type '?' or 'h' for help"); | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | next unless $command; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $self->term->addhistory($command) if $command =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | sub help { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
help: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $self->print(<<HELP); | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | command argument description | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | repo :user :repo set owner/repo, eg: 'fayland perl-app-github' | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | login :login :pass authenticated as :login | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | loadcfg authed by git config --global github.user|pass | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | ?,h help | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | q,exit,quit exit | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | Repos | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | r.show more in-depth information for the :repo | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | r.list list out all the repositories for the :user | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | r.watch watch repositories (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | r.unwatch unwatch repositories (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | r.fork fork a repository (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | r.create create a new repository (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | r.set_private set a public repo private (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | r.set_public set a private repo public (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | r.commit :sha1 show a specific commit | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | Issues | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | i.list open|closed see a list of issues for a project | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | i.view :number get data on an individual issue by number | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | i.open open a new issue (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | i.close :number close an issue (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | i.reopen :number reopen an issue (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | i.edit :number edit an issue (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | i.comment :number | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | i.label add|del :num :label | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | add/remove a label (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | Users | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | u.show get extended information on user | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | u.update update your users info (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | u.followers | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | u.following | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | u.follow :user follow :user (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | u.unfollow :user unfollow :user (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 257 | u.pub_keys Public Key Management (auth required) | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | u.pub_keys.add | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | u.pub_keys.del :number | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | Objects | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | o.tree :tree_sha1 get the contents of a tree by tree sha | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | o.trees :tree_sha1 get the contents of a tree by tree sha and recursively descend down the tree | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | o.blob :sha1 get the data of a blob (tree, file or commits) | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | Others | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | r.show :user :repo more in-depth information for a repository | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | r.list :user list out all the repositories for a user | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | u.show :user get extended information on :user | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | HELP | ||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | sub set_repo { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_repo: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my ( $self, $repo ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # validate | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | unless ( $repo =~ $self->repo_regexp ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $self->print("Wrong repo args ($repo), eg 'fayland perl-app-github'"); | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my ( $owner, $name ) = ( $repo =~ $self->repo_regexp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $self->{_data}->{owner} = $owner; | |||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->{_data}->{repo} = $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # when call 'login' before 'repo' | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | my @logins = ( $self->{_data}->{login} and $self->{_data}->{pass} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | ? ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 288 | login => $self->{_data}->{login}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | pass => $self->{_data}->{pass} | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | : (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_data"}{"login"} and $self->{"_data"}{"pass"}
MC/DC0%0/2
$self->{"_data"}{"login"} and $self->{"_data"}{"pass"}
$self->{"_data"}{"login"}
$self->{"_data"}{"pass"}
Truth table0%0/3
A and B
A= $self->{"_data"}{"login"}B= $self->{"_data"}{"pass"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | $self->{github} = Net::GitHub->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | owner => $owner, | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | repo => $name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | version => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | pass => $self->{_data}->{pass}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | @logins, | |||||||||||||||||||||||||||||||||||||||||||||
| 299 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $self->{prompt} = "$owner/$name> "; | |||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub set_login { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_login: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my ( $self, $login ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ( $login, my $pass ) = split( /\s+/, $login, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | unless ( $login and $pass ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$login and $pass
MC/DC0%0/2
$login and $pass
$login
$pass
Truth table0%0/3
A and B
A= $loginB= $pass
| |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $self->print("Wrong login args ($login $pass), eg fayland password"); | |||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $self->_do_login( $login, $pass ); | |||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub set_loadcfg { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_loadcfg: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my ( $self, $ign ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | my $login = `git config --global github.user`; | |||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my $pass = `git config --global github.pass`; | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | chomp($login); | |||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | chomp($pass); | |||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | unless ( ( $login and $pass ) or $ign ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$login and $pass or $ign
$login and $pass
MC/DC0%0/3
$login and $pass or $ign
$login
$pass
$ign
Truth table0%0/5
A and B or C
A= $loginB= $passC= $ign
| |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $self->print("run git config --global github.user|pass fails"); | |||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | $self->_do_login( $login, $pass ) if $login and $pass; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$login and $pass
MC/DC0%0/2
$login and $pass
$login
$pass
Truth table0%0/3
A and B
A= $loginB= $pass
| |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | sub _do_login { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_do_login: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my ( $self, $login, $pass ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | # save for set_repo | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $self->{_data}->{login} = $login; | |||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $self->{_data}->{pass} = $pass; | |||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ( $self->{_data}->{repo} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | $self->{github} = Net::GitHub->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | version => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | owner => $self->{_data}->{owner}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | repo => $self->{_data}->{repo}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | login => $self->{_data}->{login}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | pass => $self->{_data}->{pass} | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # Create a Net::GitHub object with the owner set to the logged in user | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # Super convenient if you don't want to set a user first | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | $self->{github} = Net::GitHub->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | version => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | login => $self->{_data}->{login}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | pass => $self->{_data}->{pass}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | owner => $self->{_data}->{login} | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | sub run_github { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_github: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my ( $self, $c1, $c2 ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | unless ( $self->github ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | croak "not auth" if $self->silent; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $self->print( | |||||||||||||||||||||||||||||||||||||||||||||
| 365 | q~not enough information. try calling login :user :pass or loadcfg~ | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my @args = splice( @_, 3, scalar @_ - 3 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my $result = $self->github->$c1->$c2(@args); | |||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # o.blob return plain text | ||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | if ( ref $result ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $result = JSON::XS->new->utf8->pretty->encode($result); | |||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $self->print($result); | |||||||||||||||||||||||||||||||||||||||||||||
| 379 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # custom error | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | if ( $@ =~ /login and pass are required/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | croak "not auth" if $self->silent; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $self->print( | |||||||||||||||||||||||||||||||||||||||||||||
| 387 | qq~authentication required.\ntry 'login :owner :pass' or 'loadcfg' first\n~ | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | croak $@ if $self->silent; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $self->print_err($@); | |||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | sub run_github_with_repo { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_github_with_repo: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my ($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | unless ( $self->{_data}->{repo} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $self->print(q~no repo specified. try calling repo :owner :repo~); | |||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||
| 405 | $self->run_github( | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | shift, shift, | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | $self->{_data}->{owner}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | $self->{_data}->{repo}, @_ | ||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | sub run_basic_repo_cmd { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_basic_repo_cmd: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my ( $self, $obj, $meth, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | if ( $args and $args =~ $self->repo_regexp ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args and $args =~ $self->repo_regexp
MC/DC0%0/2
$args and $args =~ $self->repo_regexp
$args
$args =~ $self->repo_regexp
Truth table0%0/3
A and B
A= $argsB= $args =~ $self->repo_regexp
| |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | $self->run_github( $obj, $meth, $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | $self->run_github_with_repo( $obj, $meth ); | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||
| 423 | ################## Repos | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub repo_list { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repo_list: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | if ( $args and $args =~ /^[\w\-]+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args and $args =~ /^[\w\-]+$/
MC/DC0%0/2
$args and $args =~ /^[\w\-]+$/
$args
$args =~ /^[\w\-]+$/
Truth table0%0/3
A and B
A= $argsB= $args =~ /^[\w\-]+$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $self->run_github( 'repos', 'list', $args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 429 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $self->run_github( 'repos', 'list' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | sub repo_create { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repo_create: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my ($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my %data; | |||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | unless (@_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | foreach my $col ( 'name', 'description', 'homepage' ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my $data = $self->read( ucfirst($col) . ': ' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | $data{$col} = $data; | |||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ( $data{name}, $data{description}, $data{homepage} ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | unless ( length( $data{name} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $self->print('create repo failed. name is required'); | |||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $self->run_github( 'repos', 'create', \%data ); | |||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | sub repo_update { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repo_update: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my ( $self, $param, $value, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | if ( $args and $args =~ $self->repo_regexp ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args and $args =~ $self->repo_regexp
MC/DC0%0/2
$args and $args =~ $self->repo_regexp
$args
$args =~ $self->repo_regexp
Truth table0%0/3
A and B
A= $argsB= $args =~ $self->repo_regexp
| |||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $self->run_github( 'repos', 'update', $1, $2, | |||||||||||||||||||||||||||||||||||||||||||||
| 461 | { $param => $value, name => $2 } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 463 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | unless ( $self->{_data}->{repo} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | $self->print(q~no repo specified. try calling repo :owner :repo~); | |||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||
| 469 | $self->run_github_with_repo( 'repos', 'update', | ||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | { $param => $value, name => $self->{_data}->{repo} } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | # Issues | ||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | sub issue_open_or_edit { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
issue_open_or_edit: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my ( $self, $type, $number ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | if ( $type eq 'edit' and $number !~ /^\d+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$type eq "edit" and not $number =~ /^\d+$/
MC/DC0%0/2
$type eq "edit" and not $number =~ /^\d+$/
$type eq "edit"
not $number =~ /^\d+$/
Truth table0%0/3
A and not(B)
A= $type eq "edit"B= not $number =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | $self->print('unknown argument. i.edit :number'); | |||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my $title = $self->read('Title: '); | |||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my $body = $self->read('Body (use EOF to submit, use QUIT to cancel): '); | |||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | while ( my $data = $self->read('> ') ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | last if ( $data eq 'EOF' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | return if ( $data eq 'QUIT' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $body .= "\n" . $data; | |||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | if ( $type eq 'edit' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | $self->run_github_with_repo( 'issue', 'update_issue', $number, | |||||||||||||||||||||||||||||||||||||||||||||
| 493 | { title => $title, body => $body } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 495 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | $self->run_github_with_repo( 'issue', 'create_issue', | |||||||||||||||||||||||||||||||||||||||||||||
| 497 | { title => $title, body => $body } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | sub issue_label { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
issue_label: not called CC=3 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 1 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | my ( $type, $number, $label ) = split( /\s+/, $args, 3 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | if ( $type eq 'add' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | $self->run_github_with_repo( 'issue', 'create_issue_label', $number, | |||||||||||||||||||||||||||||||||||||||||||||
| 508 | [$label] ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 510 | elsif ( $type eq 'del' ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $self->run_github_with_repo( 'issue', 'delete_issue_label', $number, | |||||||||||||||||||||||||||||||||||||||||||||
| 512 | $label ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 514 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $self->print('unknown argument. i.label add|del :number :label'); | |||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | sub issue_comment { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
issue_comment: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | my ( $self, $number ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | if ( $number !~ /^\d+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $self->print('unknown argument. i.comment :number'); | |||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | my $body = $self->read('Comment (use EOF to submit, use QUIT to cancel): '); | |||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | while ( my $data = $self->read('> ') ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | last if ( $data eq 'EOF' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | return if ( $data eq 'QUIT' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | $body .= "\n" . $data; | |||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | $self->run_github_with_repo( 'issue', 'create_comment', $number, | |||||||||||||||||||||||||||||||||||||||||||||
| 535 | { body => $body } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||
| 538 | ################## Users | ||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | sub user_update { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
user_update: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | my ( $self, $type ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||
| 542 | # name, email, blog, company, location | ||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | while ( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$type and grep {$_ eq $type;} "name", "email", "blog", "company", "location"
MC/DC0%0/2
$type and grep {$_ eq $type;} "name", "email", "blog", "company", "location"
$type
grep {$_ eq $type;} "name", "email", "blog", "company", "location"
Truth table0%0/3
A and B
A= $typeB= grep {$_ eq $type;} "name", "email", "blog", "company", "location"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 544 | !( | ||||||||||||||||||||||||||||||||||||||||||||||
| 545 | $type | ||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | and ( grep { $_ eq $type } (qw/name email blog company location/) ) | |||||||||||||||||||||||||||||||||||||||||||||
| 547 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 548 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 549 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | $type = | |||||||||||||||||||||||||||||||||||||||||||||
| 551 | $self->read('Update Key: (name, email, blog, company, location): '); | ||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | my $value = $self->read('Value: '); | |||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | $self->run_github( 'user', 'update', $type, $value ); | |||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | sub user_pub_keys { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
user_pub_keys: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | my ( $self, $type, $number, $key ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | if ( $type eq 'show' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $self->run_github( 'user', 'keys' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 564 | elsif ( $type eq 'add' ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my ( $name, $keyv ); | |||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | unless ( $number and $key ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$number and $key
MC/DC0%0/2
$number and $key
$number
$key
Truth table0%0/3
A and B
A= $numberB= $key
| |||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $name = $self->read('Pub Key Name: '); | |||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | $keyv = $self->read('Key: '); | |||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 570 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | $name = $number; | |||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | $keyv = $key; | |||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | return $self->run_github( 'user', 'create_key', | |||||||||||||||||||||||||||||||||||||||||||||
| 576 | { title => $name, key => $keyv } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 578 | elsif ( $type eq 'del' ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | unless ( $number and $number =~ /^\d+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$number and $number =~ /^\d+$/
MC/DC0%0/2
$number and $number =~ /^\d+$/
$number
$number =~ /^\d+$/
Truth table0%0/3
A and B
A= $numberB= $number =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | $self->print('unknown argument. u.pub_keys.del :number'); | |||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | $self->run_github( 'user', 'delete_key', $number ); | |||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||
| 589 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||