File Coverage

blib/lib/App/GitGot/Command/remove.pm
Criterion Covered Total %
statement 34 34 100.0
branch 7 8 87.5
condition 5 9 55.5
subroutine 10 10 100.0
pod 1 2 50.0
total 57 63 90.4


line stmt bran cond sub pod time code
1             package App::GitGot::Command::remove;
2             our $AUTHORITY = 'cpan:GENEHACK';
3             $App::GitGot::Command::remove::VERSION = '1.337';
4             # ABSTRACT: remove a managed repository from your config
5 15     15   9479 use 5.014;
  15         61  
6              
7 15     15   122 use List::Util qw/ any /;
  15         31  
  15         1344  
8              
9 15     15   123 use App::GitGot -command;
  15         31  
  15         123  
10              
11 15     15   5586 use Moo;
  15         34  
  15         93  
12             extends 'App::GitGot::Command';
13 15     15   4914 use namespace::autoclean;
  15         43  
  15         119  
14              
15 45     45 1 45275 sub command_names { qw/ remove rm / }
16              
17             sub options {
18 3     3 0 402 my( $class , $app ) = @_;
19             return (
20 3         27 [ 'force' => 'FIXME' ] ,
21             );
22             }
23              
24 3     3   15 sub _use_io_page { 0 }
25              
26             sub _execute {
27 3     3   12 my( $self, $opt, $args ) = @_;
28              
29 3 100 66     72 unless ( $self->active_repos and @$args or $self->tags) {
      66        
30 1         347 say STDERR "ERROR: You need to select one or more repos to remove";
31 1         36 exit(1);
32             }
33              
34 2         158 my @new_repo_list;
35              
36 2         35 REPO: for my $repo ( $self->all_repos ) {
37 7         109 my $number = $repo->number;
38              
39 7 100   7   146 if ( any { $number == $_->number } $self->active_repos ) {
  7         346  
40 2         12 my $name = $repo->label;
41              
42 2 50 33     17 if ( $self->opt->force or $self->prompt_yn( "got rm: remove '$name'?" )) {
43 2 100       58 say "Removed repo '$name'" if $self->verbose;
44 2         95 next REPO;
45             }
46             }
47 5         21 push @new_repo_list , $repo;
48             }
49              
50 2         57 $self->set_full_repo_list( \@new_repo_list );
51 2         123 $self->write_config();
52             }
53              
54             1;
55              
56             ## FIXME docs
57              
58             __END__