| 1 | package AnyEvent::FTP::Server::Role::Help; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 25 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 25 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 25 | ▶ | use 5.010; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 25 | ▶ | use Moo::Role; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | # ABSTRACT: Help role for FTP server | ||||||||||||||
| 9 | 25 | our $VERSION = '0.19'; # VERSION | |||||||||||||
| 10 | |||||||||||||||
| 11 | |||||||||||||||
| 12 | 25 | my %cmds; | |||||||||||||
| 13 | |||||||||||||||
| 14 | 6 | ▶ | sub help_help { 'HELP [<sp> command]' } | ||||||||||||
|
Subroutine
help_help: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 15 | |||||||||||||||
| 16 | sub cmd_help | ||||||||||||||
| 17 | { | ||||||||||||||
| 18 | 108 | ▶ | my($self, $con, $req) = @_; | ||||||||||||
|
Subroutine
cmd_help: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||
| 19 | |||||||||||||||
| 20 | 108 | my $topic = $req->args; | |||||||||||||
| 21 | 108 | $topic =~ s/^\s+//; | |||||||||||||
| 22 | 108 | $topic =~ s/\s+$//; | |||||||||||||
| 23 | 108 | $topic = lc $topic; | |||||||||||||
| 24 | |||||||||||||||
| 25 | 108 | ▶ | if($topic eq '') | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 26 | { | ||||||||||||||
| 27 | 6 | my $class = ref $self; | |||||||||||||
| 28 | 6 | ▶ | unless(defined $cmds{$class}) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 29 | { | ||||||||||||||
| 30 | 25 | ▶ | no strict 'refs'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 31 | $cmds{$class} = [ | ||||||||||||||
| 32 | 4 | sort map { my $x = $_; $x =~ s/^cmd_//; uc $x } grep /^cmd_/, keys %{$class . '::'} | |||||||||||||
| 33 | ]; | ||||||||||||||
| 34 | } | ||||||||||||||
| 35 | |||||||||||||||
| 36 | $con->send_response(214, [ | ||||||||||||||
| 37 | 'The following commands are recognized:', | ||||||||||||||
| 38 | 6 | join(' ', @{ $cmds{$class} }), | |||||||||||||
| 39 | 'Direct comments to devnull@bogus', | ||||||||||||||
| 40 | ]); | ||||||||||||||
| 41 | } | ||||||||||||||
| 42 | elsif($self->can("cmd_$topic")) | ||||||||||||||
| 43 | { | ||||||||||||||
| 44 | 99 | my $method = "help_$topic"; | |||||||||||||
| 45 | 99 | ▶ | if($self->can("help_$topic")) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 46 | { | ||||||||||||||
| 47 | 99 | $con->send_response(214 => 'Syntax: ' . $self->$method) | |||||||||||||
| 48 | } | ||||||||||||||
| 49 | else | ||||||||||||||
| 50 | { | ||||||||||||||
| 51 | 0 | $con->send_response(502 => uc($topic) . " is a command without help"); | |||||||||||||
| 52 | } | ||||||||||||||
| 53 | } | ||||||||||||||
| 54 | else | ||||||||||||||
| 55 | { | ||||||||||||||
| 56 | 3 | $con->send_response(502 => 'Unknown command'); | |||||||||||||
| 57 | } | ||||||||||||||
| 58 | |||||||||||||||
| 59 | 108 | $self->done; | |||||||||||||
| 60 | } | ||||||||||||||
| 61 | |||||||||||||||
| 62 | 25 | 1; | |||||||||||||
| 63 | |||||||||||||||
| 64 | __END__ | ||||||||||||||