| 1 | package App::CmdDirs; | ||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 2 | ▶ | use Cwd; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 2 | ▶ | use App::CmdDirs::Traverser::Base; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 2 | our $VERSION; | |||||||||||||||||||
| 10 | 2 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 2 | $VERSION = '1.02'; | |||||||||||||||||||
| 12 | } | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 2 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 15 | 2 | my ($class, $argv, $options) = @_; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 2 | my $self = {}; | |||||||||||||||||||
| 18 | 2 | $self->{'argv'} = $argv; | |||||||||||||||||||
| 19 | 2 | $self->{'options'} = $options; | |||||||||||||||||||
| 20 | 2 | bless $self, $class; | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 2 | return $self; | |||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | # Find directories to act upon, choose a traverser, and go | ||||||||||||||||||||
| 26 | 2 | ▶ | sub run { | ||||||||||||||||||
|
Subroutine
run: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||
| 27 | 2 | my ($self) = @_; | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | # Pull working dir & post-option arguments | ||||||||||||||||||||
| 30 | 2 | my $topDir = cwd(); | |||||||||||||||||||
| 31 | 2 | my @argv = @{$self->{'argv'}}; | |||||||||||||||||||
| 32 | 2 | my $command = $argv[0]; | |||||||||||||||||||
| 33 | 2 | my @dirs; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | # Get any dirs passed on the command line | ||||||||||||||||||||
| 36 | 2 | ▶ | foreach (my $x = 1; $x < scalar(@argv); $x++) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | 0 | push @dirs, $argv[$x]; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | # No directories passed, glob all | ||||||||||||||||||||
| 41 | 2 | ▶ | if ($#dirs == -1) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | 2 | ▶ | @dirs = glob '*'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 2 | my $traverser = $self->getTraverser($command, $topDir, \@dirs); | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 2 | $traverser->traverse($self->{'options'}->{'quiet'}); | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 2 | return 1; | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | # Create a traverser for specific command types | ||||||||||||||||||||
| 53 | 2 | ▶ | sub getTraverser { | ||||||||||||||||||
|
Subroutine
getTraverser: called CC=6 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||
| 54 | 2 | my ($self, $command, $topDir, $dirs) = @_; | |||||||||||||||||||
| 55 | 2 | my $traverser; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 2 | ▶ | if ($self->{'options'}{'all'}) { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 58 | 0 | $traverser = App::CmdDirs::Traverser::Base->new($command, $topDir, $dirs); | |||||||||||||||||||
| 59 | ▶ | } elsif ($self->{'options'}->{'git'} || $command =~ /git/) { | |||||||||||||||||||
|
Condition66%2/3
$self->{"options"}{"git"} or $command =~ /git/
MC/DC50%1/2
$self->{"options"}{"git"} or $command =~ /git/
$self->{"options"}{"git"}
$command =~ /git/
Truth table66%2/3
A or B
A= $self->{"options"}{"git"}B= $command =~ /git/
| |||||||||||||||||||||
| 60 | 1 | require App::CmdDirs::Traverser::Git; | |||||||||||||||||||
| 61 | 1 | $traverser = App::CmdDirs::Traverser::Git->new($command, $topDir, $dirs); | |||||||||||||||||||
| 62 | ▶ | } elsif ($self->{'options'}->{'svn'} || $command =~ /svn/) { | |||||||||||||||||||
|
Condition33%1/3
$self->{"options"}{"svn"} or $command =~ /svn/
MC/DC0%0/2
$self->{"options"}{"svn"} or $command =~ /svn/
$self->{"options"}{"svn"}
$command =~ /svn/
Truth table33%1/3
A or B
A= $self->{"options"}{"svn"}B= $command =~ /svn/
| |||||||||||||||||||||
| 63 | 1 | require App::CmdDirs::Traverser::Subversion; | |||||||||||||||||||
| 64 | 1 | $traverser = App::CmdDirs::Traverser::Subversion->new($command, $topDir, $dirs); | |||||||||||||||||||
| 65 | } else { | ||||||||||||||||||||
| 66 | 0 | $traverser = App::CmdDirs::Traverser::Base->new($command, $topDir, $dirs); | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 2 | return $traverser; | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 2 | 1; | |||||||||||||||||||