line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Shell::Amazon::S3; |
2
|
1
|
|
|
1
|
|
455
|
use Term::ReadLine; |
|
1
|
|
|
|
|
2171
|
|
|
1
|
|
|
|
|
23
|
|
3
|
1
|
|
|
1
|
|
499
|
use Moose; |
|
1
|
|
|
|
|
306253
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
5301
|
use namespace::clean -except => ['meta']; |
|
1
|
|
|
|
|
4545
|
|
|
1
|
|
|
|
|
6
|
|
5
|
1
|
|
|
1
|
|
563
|
use Shell::Amazon::S3::CommandDispatcher; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
6
|
1
|
|
|
1
|
|
511
|
use Shell::Amazon::S3::ConfigLoader; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
7
|
1
|
|
|
1
|
|
568
|
use Perl6::Say; |
|
1
|
|
|
|
|
575
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.04_02'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'MooseX::Object::Pluggable'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'term' => ( |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
required => 1, |
16
|
|
|
|
|
|
|
default => sub { Term::ReadLine->new('Amazon S3 shell') } |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'prompt' => ( |
20
|
|
|
|
|
|
|
is => 'rw', |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
default => sub {'psh3ll> '} |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has 'out_fh' => ( |
26
|
|
|
|
|
|
|
is => 'rw', |
27
|
|
|
|
|
|
|
required => 1, |
28
|
|
|
|
|
|
|
lazy => 1, |
29
|
|
|
|
|
|
|
default => sub { shift->term->OUT || \*STDOUT; } |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has 'dispatcher' => ( |
33
|
|
|
|
|
|
|
is => 'rw', |
34
|
|
|
|
|
|
|
required => 1, |
35
|
|
|
|
|
|
|
default => sub { Shell::Amazon::S3::CommandDispatcher->new } |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub run { |
39
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
40
|
0
|
|
|
|
|
|
$self->show_banner; |
41
|
0
|
|
|
|
|
|
$self->setup; |
42
|
0
|
|
|
|
|
|
while ( $self->run_once ) { |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# keep looping |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub setup { |
49
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
50
|
0
|
|
|
|
|
|
$self->setup_config; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub setup_config { |
54
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
55
|
0
|
|
|
|
|
|
my $config_loader = Shell::Amazon::S3::ConfigLoader->new; |
56
|
0
|
|
|
|
|
|
$config_loader->load; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub run_once { |
60
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
61
|
0
|
|
|
|
|
|
my $line = $self->read; |
62
|
0
|
0
|
|
|
|
|
return unless defined($line); # undefined value == EOF |
63
|
0
|
|
|
|
|
|
my $result = $self->eval($line); |
64
|
0
|
|
|
|
|
|
eval { $self->print($result); }; |
|
0
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
if ($@) { |
66
|
0
|
|
|
|
|
|
my $error = $@; |
67
|
0
|
|
|
|
|
|
eval { $self->print("Error printing! - $error\n"); }; |
|
0
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
return 1; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub read { |
73
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
74
|
0
|
|
|
|
|
|
return $self->term->readline( $self->prompt ); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub eval { |
78
|
0
|
|
|
0
|
0
|
|
my ( $self, $line ) = @_; |
79
|
0
|
|
|
|
|
|
my ( $command, $args ) = $self->parse_input($line); |
80
|
0
|
0
|
|
|
|
|
return unless defined($command); |
81
|
0
|
|
|
|
|
|
my $result = $self->execute( $command, $args ); |
82
|
0
|
0
|
|
|
|
|
exit if $result eq 'EXIT'; |
83
|
0
|
|
|
|
|
|
return $result; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub parse_input { |
87
|
0
|
|
|
0
|
0
|
|
my ( $self, $line ) = @_; |
88
|
0
|
|
|
|
|
|
my @tokens = split( /\s/, $line ); |
89
|
0
|
0
|
|
|
|
|
return unless @tokens >= 1; |
90
|
0
|
|
|
|
|
|
my $command = shift @tokens; |
91
|
0
|
|
|
|
|
|
return ( $command, \@tokens ); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub execute { |
95
|
0
|
|
|
0
|
0
|
|
my ( $self, $command, $args ) = @_; |
96
|
0
|
|
|
|
|
|
my $result = eval { $self->dispatcher->dispatch( $command, $args ); }; |
|
0
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
return $self->error_return( "Runtime error", $@ ) if $@; |
98
|
0
|
|
|
|
|
|
return $result; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub error_return { |
102
|
0
|
|
|
0
|
0
|
|
my ( $self, $type, $error ) = @_; |
103
|
0
|
|
|
|
|
|
return "${type}: ${error}"; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub print { |
107
|
0
|
|
|
0
|
0
|
|
my ( $self, $result ) = @_; |
108
|
0
|
|
|
|
|
|
my $fh = $self->out_fh; |
109
|
1
|
|
|
1
|
|
529
|
no warnings 'uninitialized'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
112
|
|
110
|
0
|
|
|
|
|
|
print $fh "$result"; |
111
|
0
|
0
|
|
|
|
|
print $fh "\n" if $self->term->ReadLine =~ /Gnu/; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub show_banner { |
115
|
0
|
|
|
0
|
0
|
|
say "Welcome to pSh3ll (Amazon S3 command shell for Perl) (c) 2008 Takatoshi Kitano."; |
116
|
0
|
|
|
|
|
|
say "Type 'help' for command list."; |
117
|
0
|
|
|
|
|
|
say ; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 NAME |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Shell::Amazon::S3 - Shell for Amazon S3 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 SYNOPSIS |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
use Shell::Amazon::S3; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
my $shell = Shell::Amazon::S3->new; |
133
|
|
|
|
|
|
|
$shell->load_plugins($_) for qw(ReadLineHistory Completion); |
134
|
|
|
|
|
|
|
$shell->run; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Alternatively, use the 'psh3ll.pl' script installed with the distribution |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
system$ psh3ll.pl |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 DESCRIPTION |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Shell::Amazon::S3 is Shell for Amazon S3 |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Takatoshi KitanoE<lt>kitano.t@gmail.comE<gt> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 SEE ALSO |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 LICENSE |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
153
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |