line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::FTP::Server::Role::Help; |
2
|
|
|
|
|
|
|
|
3
|
25
|
|
|
25
|
|
13502
|
use strict; |
|
25
|
|
|
|
|
50
|
|
|
25
|
|
|
|
|
643
|
|
4
|
25
|
|
|
25
|
|
100
|
use warnings; |
|
25
|
|
|
|
|
44
|
|
|
25
|
|
|
|
|
502
|
|
5
|
25
|
|
|
25
|
|
374
|
use 5.010; |
|
25
|
|
|
|
|
69
|
|
6
|
25
|
|
|
25
|
|
127
|
use Moo::Role; |
|
25
|
|
|
|
|
66
|
|
|
25
|
|
|
|
|
170
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Help role for FTP server |
9
|
|
|
|
|
|
|
our $VERSION = '0.19'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %cmds; |
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
6
|
0
|
21
|
sub help_help { 'HELP [ command]' } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub cmd_help |
17
|
|
|
|
|
|
|
{ |
18
|
108
|
|
|
108
|
0
|
165
|
my($self, $con, $req) = @_; |
19
|
|
|
|
|
|
|
|
20
|
108
|
|
|
|
|
178
|
my $topic = $req->args; |
21
|
108
|
|
|
|
|
212
|
$topic =~ s/^\s+//; |
22
|
108
|
|
|
|
|
184
|
$topic =~ s/\s+$//; |
23
|
108
|
|
|
|
|
158
|
$topic = lc $topic; |
24
|
|
|
|
|
|
|
|
25
|
108
|
100
|
|
|
|
424
|
if($topic eq '') |
|
|
100
|
|
|
|
|
|
26
|
|
|
|
|
|
|
{ |
27
|
6
|
|
|
|
|
15
|
my $class = ref $self; |
28
|
6
|
100
|
|
|
|
23
|
unless(defined $cmds{$class}) |
29
|
|
|
|
|
|
|
{ |
30
|
25
|
|
|
25
|
|
9724
|
no strict 'refs'; |
|
25
|
|
|
|
|
55
|
|
|
25
|
|
|
|
|
5049
|
|
31
|
|
|
|
|
|
|
$cmds{$class} = [ |
32
|
4
|
|
|
|
|
8
|
sort map { my $x = $_; $x =~ s/^cmd_//; uc $x } grep /^cmd_/, keys %{$class . '::'} |
|
70
|
|
|
|
|
75
|
|
|
70
|
|
|
|
|
100
|
|
|
70
|
|
|
|
|
126
|
|
|
4
|
|
|
|
|
143
|
|
33
|
|
|
|
|
|
|
]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$con->send_response(214, [ |
37
|
|
|
|
|
|
|
'The following commands are recognized:', |
38
|
6
|
|
|
|
|
27
|
join(' ', @{ $cmds{$class} }), |
|
6
|
|
|
|
|
43
|
|
39
|
|
|
|
|
|
|
'Direct comments to devnull@bogus', |
40
|
|
|
|
|
|
|
]); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif($self->can("cmd_$topic")) |
43
|
|
|
|
|
|
|
{ |
44
|
99
|
|
|
|
|
151
|
my $method = "help_$topic"; |
45
|
99
|
50
|
|
|
|
290
|
if($self->can("help_$topic")) |
46
|
|
|
|
|
|
|
{ |
47
|
99
|
|
|
|
|
307
|
$con->send_response(214 => 'Syntax: ' . $self->$method) |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else |
50
|
|
|
|
|
|
|
{ |
51
|
0
|
|
|
|
|
0
|
$con->send_response(502 => uc($topic) . " is a command without help"); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else |
55
|
|
|
|
|
|
|
{ |
56
|
3
|
|
|
|
|
9
|
$con->send_response(502 => 'Unknown command'); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
108
|
|
|
|
|
313
|
$self->done; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |