| 1 | package App::BCSSH; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strictures 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 1 | our $VERSION = '0.002002'; | |||||||||||||||||||||||||||
| 5 | 1 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Module::Runtime qw(require_module); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use App::BCSSH::Util qw(command_to_package rc_dir); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Module::Find (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub run_script { exit($_[0]->new(@ARGV)->run ? 0 : 1) } | ||||||||||||||||||||||||||
|
Subroutine
run_script: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub new { bless { args => [@_[1..$#_]] }, $_[0] } | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||
|
Subroutine
run: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 18 | 0 | my @args = @{ $self->{args} }; | |||||||||||||||||||||||||||
| 19 | 0 | $self->load_plugins(rc_dir); | |||||||||||||||||||||||||||
| 20 | 0 | ▶ | my $command = shift @args | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | or die "Command required.\n" . $self->_commands_msg; | ||||||||||||||||||||||||||||
| 22 | 0 | ▶ | $command =~ /^[a-z]+(?:-[a-z]+)+$/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | or $self->invalid_command($command); | ||||||||||||||||||||||||||||
| 24 | 0 | ▶ | return try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 25 | 0 | my $pack = command_to_package($command); | |||||||||||||||||||||||||||
| 26 | 0 | require_module($pack); | |||||||||||||||||||||||||||
| 27 | 0 | ▶ | return($pack->can('new') ? $pack->new(@args)->run : $pack->run(@args)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | 0 | ▶ | catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if (/Can't locate .+? in \@INC/ && tr/\n// < 2 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
/Can't locate .+? in \@INC/ and tr/\n// < 2
MC/DC0%0/2
/Can't locate .+? in \@INC/ and tr/\n// < 2
/Can't locate .+? in \@INC/
tr/\n// < 2
Truth table0%0/3
A and B
A= /Can't locate .+? in \@INC/B= tr/\n// < 2
| |||||||||||||||||||||||||||||
| 31 | 0 | $self->invalid_command($command); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | else { | ||||||||||||||||||||||||||||
| 34 | 0 | die $_; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 0 | }; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub invalid_command { | ||||||||||||||||||||||||||
|
Subroutine
invalid_command: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 41 | 0 | my $command = shift; | |||||||||||||||||||||||||||
| 42 | 0 | die "Invalid command $command!\n" . $self->_commands_msg; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub _commands_msg { | ||||||||||||||||||||||||||
|
Subroutine
_commands_msg: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 46 | 0 | require App::BCSSH::Command::commands; | |||||||||||||||||||||||||||
| 47 | 0 | App::BCSSH::Command::commands->new->commands_message; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub load_plugins { | ||||||||||||||||||||||||||
|
Subroutine
load_plugins: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 52 | 0 | my $dir = shift; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | return unless -d $dir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | require File::Find; | |||||||||||||||||||||||||||
| 55 | 0 | ▶ | File::Find::find({ no_chdir => 1, wanted => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | return unless -f; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | return unless /\.pm$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | require $_; | |||||||||||||||||||||||||||
| 59 | 0 | }}, $dir); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 1 | 1; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||