line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::CmdDirs; |
2
|
2
|
|
|
2
|
|
98067
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
74
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use Cwd; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
303
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
979
|
use App::CmdDirs::Traverser::Base; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
104
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION; |
10
|
|
|
|
|
|
|
BEGIN { |
11
|
2
|
|
|
2
|
|
902
|
$VERSION = '1.02'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
2
|
|
|
2
|
0
|
10247
|
my ($class, $argv, $options) = @_; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
4
|
my $self = {}; |
18
|
2
|
|
|
|
|
6
|
$self->{'argv'} = $argv; |
19
|
2
|
|
|
|
|
5
|
$self->{'options'} = $options; |
20
|
2
|
|
|
|
|
5
|
bless $self, $class; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
8
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Find directories to act upon, choose a traverser, and go |
26
|
|
|
|
|
|
|
sub run { |
27
|
2
|
|
|
2
|
0
|
9
|
my ($self) = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Pull working dir & post-option arguments |
30
|
2
|
|
|
|
|
10545
|
my $topDir = cwd(); |
31
|
2
|
|
|
|
|
30
|
my @argv = @{$self->{'argv'}}; |
|
2
|
|
|
|
|
43
|
|
32
|
2
|
|
|
|
|
9
|
my $command = $argv[0]; |
33
|
2
|
|
|
|
|
8
|
my @dirs; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Get any dirs passed on the command line |
36
|
2
|
|
|
|
|
23
|
foreach (my $x = 1; $x < scalar(@argv); $x++) { |
37
|
0
|
|
|
|
|
0
|
push @dirs, $argv[$x]; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# No directories passed, glob all |
41
|
2
|
50
|
|
|
|
15
|
if ($#dirs == -1) { |
42
|
2
|
|
|
|
|
280
|
@dirs = glob '*'; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
26
|
my $traverser = $self->getTraverser($command, $topDir, \@dirs); |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
29
|
$traverser->traverse($self->{'options'}->{'quiet'}); |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
228
|
return 1; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Create a traverser for specific command types |
53
|
|
|
|
|
|
|
sub getTraverser { |
54
|
2
|
|
|
2
|
0
|
5
|
my ($self, $command, $topDir, $dirs) = @_; |
55
|
2
|
|
|
|
|
8
|
my $traverser; |
56
|
|
|
|
|
|
|
|
57
|
2
|
50
|
66
|
|
|
123
|
if ($self->{'options'}{'all'}) { |
|
|
100
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
$traverser = App::CmdDirs::Traverser::Base->new($command, $topDir, $dirs); |
59
|
|
|
|
|
|
|
} elsif ($self->{'options'}->{'git'} || $command =~ /git/) { |
60
|
1
|
|
|
|
|
1147
|
require App::CmdDirs::Traverser::Git; |
61
|
1
|
|
|
|
|
19
|
$traverser = App::CmdDirs::Traverser::Git->new($command, $topDir, $dirs); |
62
|
|
|
|
|
|
|
} elsif ($self->{'options'}->{'svn'} || $command =~ /svn/) { |
63
|
1
|
|
|
|
|
1017
|
require App::CmdDirs::Traverser::Subversion; |
64
|
1
|
|
|
|
|
25
|
$traverser = App::CmdDirs::Traverser::Subversion->new($command, $topDir, $dirs); |
65
|
|
|
|
|
|
|
} else { |
66
|
0
|
|
|
|
|
0
|
$traverser = App::CmdDirs::Traverser::Base->new($command, $topDir, $dirs); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
10
|
return $traverser; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |