lib/Shell/Amazon/S3/Command/help.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 55 SCAR 6.9
CC
1
Cov
0%
execute
2.0
get_command_summary
2.0
execute2
2.0
CRAP 2.0
1 package Shell::Amazon::S3::Command::help;
2 use Moose;
3 use Module::Find;
4 use Shell::Amazon::S3::Utils;
5  
6 extends 'Shell::Amazon::S3::Command';
7  
8 has "+desc" => ( default => 'help', );
9  
10 override 'validate_tokens', sub {
11 my ( $self, $tokens ) = @_;
12 if ( @{$tokens} != 0 ) {
13 return ( 0, "error: This command doesn't need arguments" );
14 }
15 return ( 1, "" );
16 };
17  
18 override 'parse_tokens', sub {
19 my ( $self, $tokens ) = @_;
20 return $tokens;
21 };
22  
23 sub execute {
24 my ( $self, $args ) = @_;
25 my @commands = findsubmod Shell::Amazon::S3::Command;
26 my $str = '';
27 foreach my $command ( sort @commands ) {
28 $str .= $self->get_command_summary($command->new) . "\n";
29 }
30  
31 return $str;
32  
33 }
34  
35 sub get_command_summary {
36 my ($self, $command) = @_;
37 my $desc = $command->desc;
38 sprintf("%20s -- $desc", Shell::Amazon::S3::Utils->classsuffix(ref $command));
39 }
40  
41 # FIXME: MOVE TO help doc to each command
42 sub execute2 {
43 my ( $self, $args ) = @_;
44  
45 my $result = '';
46 $result .= "get <id>\n";
47 $result .= "getacl ['bucket'|'item'] <id>\n";
48 $result .= "gettorrent <id>\n";
49 $result .= "head ['bucket'|'item'] <id>\n";
50 $result .= "host [hostname]\n";
51 $result .= "list [prefix] [max]\n";
52 $result .= "listatom [prefix] [max]\n";
53 $result .= "listrss [prefix] [max]\n";
54 $result .= "pass [password]\n";
55 $result .= "put <id> <data>\n";
56 # putfile <id> <file>
57 $result .= "quit\n";
58 $result .= "user [username]\n";
59  
60 return $result;
61 }
62  
63 1;