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.339';
4             # ABSTRACT: remove a managed repository from your config
5 15     15   9479 use 5.014;
  15         58  
6              
7 15     15   107 use List::Util qw/ any /;
  15         41  
  15         1316  
8              
9 15     15   113 use App::GitGot -command;
  15         31  
  15         127  
10              
11 15     15   5206 use Moo;
  15         42  
  15         85  
12             extends 'App::GitGot::Command';
13 15     15   5196 use namespace::autoclean;
  15         43  
  15         103  
14              
15 45     45 1 45640 sub command_names { qw/ remove rm / }
16              
17             sub options {
18 3     3 0 512 my( $class , $app ) = @_;
19             return (
20 3         28 [ 'force' => 'FIXME' ] ,
21             );
22             }
23              
24 3     3   14 sub _use_io_page { 0 }
25              
26             sub _execute {
27 3     3   11 my( $self, $opt, $args ) = @_;
28              
29 3 100 66     65 unless ( $self->active_repos and @$args or $self->tags) {
      66        
30 1         312 say STDERR "ERROR: You need to select one or more repos to remove";
31 1         35 exit(1);
32             }
33              
34 2         146 my @new_repo_list;
35              
36 2         36 REPO: for my $repo ( $self->all_repos ) {
37 7         109 my $number = $repo->number;
38              
39 7 100   7   134 if ( any { $number == $_->number } $self->active_repos ) {
  7         337  
40 2         10 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       49 say "Removed repo '$name'" if $self->verbose;
44 2         101 next REPO;
45             }
46             }
47 5         20 push @new_repo_list , $repo;
48             }
49              
50 2         46 $self->set_full_repo_list( \@new_repo_list );
51 2         127 $self->write_config();
52             }
53              
54             1;
55              
56             ## FIXME docs
57              
58             __END__