Net/Script/Run.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 45 CC 5 SCAR 26.1
CC
5
Cov
0%
run
30.0
options
2.0
BEGIN
2.0
CRAP 13.7
1 use strict;
2 use warnings;
3  
4 package Bot::Net::Script::Run;
5 use base qw/ App::CLI::Command /;
6  
7 use Bot::Net;
8 use POE;
9 use UNIVERSAL::require;
10  
11 =head1 NAME
12  
13 Bot::Net::Script::Run - Run a single server or bot
14  
15 =head1 SYNOPSIS
16  
17 # To run a server
18 bin/botnet run --server ServerName
19  
20 # To run a bot
21 bin/botnet run --bot BotName
22  
23 =head1 DESCRIPTION
24  
25 Starts a single server or bot process.
26  
27 =head1 METHODS
28  
29 =head2 options
30  
31 Returns the options used by the scrip. See L<App::CLI::Command>.
32  
33 =cut
34  
35 sub options {
36 (
37 'bot' => 'bot',
38 'server' => 'server',
39 )
40 }
41  
42 =head2 run
43  
44 Runs the requested server or bot.
45  
46 =cut
47  
48 sub run {
49 my ($self, $name) = @_;
50  
51 die "No bot or server name given to the run command. Quitting.\n"
52 unless $name;
53  
54 $name = ucfirst $name;
55 my $class = $self->{bot} ? Bot::Net->net_class('Bot', $name)
56 : $self->{server} ? Bot::Net->net_class('Server', $name)
57 : die "No --bot or --server option given.\n";
58  
59 $class->require;
60 die "Failed to load $name: $@" if $@;
61  
62 $class->setup;
63 POE::Kernel->run;
64 }
65  
66 =head1 AUTHORS
67  
68 Andrew Sterling Hanenkamp C<< <hanenkamp@cpan.org> >>
69  
70 =head1 COPYRIGHT AND LICENSE
71  
72 Copyright 2007 Boomer Consulting, Inc. All Rights Reserved.
73  
74 This program is free software and may be modified and distributed under the same terms as Perl itself.
75  
76 =cut
77  
78 1;