| 1 | package Shell::Amazon::S3::Command::count; | ||
| 2 | use Moose; | ||
| 3 | |||
| 4 | extends 'Shell::Amazon::S3::CommandWithBucket'; | ||
| 5 | |||
| 6 | has '+desc' => (default => 'count [prefix]', ); | ||
| 7 | |||
| 8 | sub execute { | ||
| 9 | my ( $self, $args ) = @_; | ||
| 10 | my $bucket = $self->bucket; | ||
| 11 | my $response = $bucket->list_all; | ||
| 12 | |||
| 13 | my $result = ''; | ||
| 14 | if ( $bucket->err ) { | ||
| 15 | $result .= $bucket->errstr; | ||
| 16 | } | ||
| 17 | else { | ||
| 18 | $result .= scalar( @{ $response->{keys} } ); | ||
| 19 | } | ||
| 20 | }; | ||
| 21 | |||
| 22 | 1; |