line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Shell::Amazon::S3::CommandDispatcher; |
2
|
1
|
|
|
1
|
|
3
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
3
|
1
|
|
|
1
|
|
4421
|
use Module::Pluggable::Object; |
|
1
|
|
|
|
|
5143
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
5
|
use Class::MOP; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
5
|
1
|
|
|
1
|
|
334
|
use Shell::Amazon::S3::Utils; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
158
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'dispatch_table' => ( |
8
|
|
|
|
|
|
|
is => 'ro', |
9
|
|
|
|
|
|
|
isa => 'HashRef', |
10
|
|
|
|
|
|
|
required => 1, |
11
|
|
|
|
|
|
|
default => sub { |
12
|
|
|
|
|
|
|
my $finder = Module::Pluggable::Object->new( |
13
|
|
|
|
|
|
|
search_path => 'Shell::Amazon::S3::Command', ); |
14
|
|
|
|
|
|
|
my @commands = $finder->plugins; |
15
|
|
|
|
|
|
|
Class::MOP::load_class($_) for @commands; |
16
|
|
|
|
|
|
|
my %table |
17
|
|
|
|
|
|
|
= map { Shell::Amazon::S3::Utils->classsuffix($_) => $_->new } |
18
|
|
|
|
|
|
|
@commands; |
19
|
|
|
|
|
|
|
\%table; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub dispatch { |
24
|
0
|
|
|
0
|
0
|
|
my ( $self, $command, $args ) = @_; |
25
|
0
|
|
|
|
|
|
my $result; |
26
|
0
|
0
|
|
|
|
|
if ( exists $self->dispatch_table->{$command} ) { |
27
|
0
|
|
|
|
|
|
$result = $self->dispatch_table->{$command}->do_execute($args); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
0
|
|
|
|
|
|
$result = 'Unknown command:' . $command; |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
|
$result; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |