line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::FTP::Server::Role::Help; |
2
|
|
|
|
|
|
|
|
3
|
25
|
|
|
25
|
|
19697
|
use strict; |
|
25
|
|
|
|
|
69
|
|
|
25
|
|
|
|
|
939
|
|
4
|
25
|
|
|
25
|
|
154
|
use warnings; |
|
25
|
|
|
|
|
70
|
|
|
25
|
|
|
|
|
708
|
|
5
|
25
|
|
|
25
|
|
562
|
use 5.010; |
|
25
|
|
|
|
|
100
|
|
6
|
25
|
|
|
25
|
|
124
|
use Moo::Role; |
|
25
|
|
|
|
|
71
|
|
|
25
|
|
|
|
|
186
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Help role for FTP server |
9
|
|
|
|
|
|
|
our $VERSION = '0.17'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %cmds; |
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
6
|
0
|
161
|
sub help_help { 'HELP [ command]' } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub cmd_help |
17
|
|
|
|
|
|
|
{ |
18
|
108
|
|
|
108
|
0
|
231
|
my($self, $con, $req) = @_; |
19
|
|
|
|
|
|
|
|
20
|
108
|
|
|
|
|
277
|
my $topic = $req->args; |
21
|
108
|
|
|
|
|
316
|
$topic =~ s/^\s+//; |
22
|
108
|
|
|
|
|
260
|
$topic =~ s/\s+$//; |
23
|
108
|
|
|
|
|
219
|
$topic = lc $topic; |
24
|
|
|
|
|
|
|
|
25
|
108
|
100
|
|
|
|
636
|
if($topic eq '') |
|
|
100
|
|
|
|
|
|
26
|
|
|
|
|
|
|
{ |
27
|
6
|
|
|
|
|
19
|
my $class = ref $self; |
28
|
6
|
100
|
|
|
|
26
|
unless(defined $cmds{$class}) |
29
|
|
|
|
|
|
|
{ |
30
|
25
|
|
|
25
|
|
14193
|
no strict 'refs'; |
|
25
|
|
|
|
|
64
|
|
|
25
|
|
|
|
|
7335
|
|
31
|
|
|
|
|
|
|
$cmds{$class} = [ |
32
|
4
|
|
|
|
|
11
|
sort map { my $x = $_; $x =~ s/^cmd_//; uc $x } grep /^cmd_/, keys %{$class . '::'} |
|
70
|
|
|
|
|
111
|
|
|
70
|
|
|
|
|
146
|
|
|
70
|
|
|
|
|
210
|
|
|
4
|
|
|
|
|
276
|
|
33
|
|
|
|
|
|
|
]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$con->send_response(214, [ |
37
|
|
|
|
|
|
|
'The following commands are recognized:', |
38
|
6
|
|
|
|
|
66
|
join(' ', @{ $cmds{$class} }), |
|
6
|
|
|
|
|
72
|
|
39
|
|
|
|
|
|
|
'Direct comments to devnull@bogus', |
40
|
|
|
|
|
|
|
]); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif($self->can("cmd_$topic")) |
43
|
|
|
|
|
|
|
{ |
44
|
99
|
|
|
|
|
275
|
my $method = "help_$topic"; |
45
|
99
|
50
|
|
|
|
466
|
if($self->can("help_$topic")) |
46
|
|
|
|
|
|
|
{ |
47
|
99
|
|
|
|
|
476
|
$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
|
|
|
|
|
15
|
$con->send_response(502 => 'Unknown command'); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
108
|
|
|
|
|
504
|
$self->done; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |