| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::gh::Command::Drop; | 
| 2 | 1 |  |  | 1 |  | 1643 | use warnings; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 31 |  | 
| 3 | 1 |  |  | 1 |  | 6 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 34 |  | 
| 4 | 1 |  |  | 1 |  | 6 | use base qw(App::gh::Command); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 225 |  | 
| 5 | 1 |  |  | 1 |  | 6 | use App::gh::Utils; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 486 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | =head1 NAME | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | App::gh::Command::Drop - drop a repository. | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | =head1 USAGE | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | $ gh drop [repository] | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | =cut | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | sub run { | 
| 18 | 0 |  |  | 0 | 0 |  | my ($self,$repo) = @_; | 
| 19 | 0 | 0 |  |  |  |  | return App::gh::Command->invoke('help', 'drop') | 
| 20 |  |  |  |  |  |  | unless defined $repo; | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 0 |  |  |  |  |  | my $gh_id = App::gh->config->github_id(); | 
| 23 | 0 |  |  |  |  |  | my $gh_token = App::gh->config->github_token(); | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 0 |  |  |  |  |  | $repo =~ s{::}{-}g; | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 0 | 0 | 0 |  |  |  | unless( $gh_id && $gh_token ) { | 
| 28 | 0 |  |  |  |  |  | die "Github authtoken not found. Can not delete repository.\n"; | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 0 |  |  |  |  |  | print "Deleting @{[ $gh_id ]}/@{[ $repo ]}\n"; | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | # repos/delete/:user/:repo | 
| 34 | 0 |  |  |  |  |  | my $uri = sprintf( qq{repos/delete/%s/%s}, $gh_id , $repo ); | 
| 35 | 0 |  |  |  |  |  | my $ret = App::gh->api->request(POST => $uri); | 
| 36 | 0 |  |  |  |  |  | my $delete_token = $ret->{delete_token}; | 
| 37 | 0 |  |  |  |  |  | $ret = App::gh->api->request(POST => $uri, delete_token => $delete_token); | 
| 38 | 0 |  |  |  |  |  | print $ret->{status} , "\n"; | 
| 39 | 0 |  |  |  |  |  | return; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | 1; |