Miril/App/Cmd/Command/server.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 35 CC 1 SCAR 6.9
CC
1
Cov
0%
opt_spec
2.0
execute
2.0
BEGIN
2.0
CRAP 2.0
1 package Miril::App::Cmd::Command::server;
2
3 use strict;
4 use warnings;
5 use autodie;
6
7 use Miril::App::Cmd -command;
8
9 use Class::Autouse;
10 Class::Autouse->autouse('Plack::Loader');
11 Class::Autouse->autouse('Miril::App::PSGI');
12
13 sub opt_spec
14 {
15 return (
16 [ 'host|h=s', "host address to bind to", { default => 'localhost' } ],
17 [ 'port|p=i', "port to listen on", { default => 8080 } ],
18 [ 'dir|d=s', "miril base dir", { default => 'example' } ],
19 [ 'site|s=s', "website", { default => 'example.com' } ],
20 );
21 }
22
23 sub execute
24 {
25 my ($self, $opt, $args) = @_;
26
27 print "Miril accepting connections at http://" . $opt->host . ":" . $opt->port ."\n";
28
29 Plack::Loader->auto(
30 host => $opt->host,
31 port => $opt->port,
32 )->run(
33 Miril::App::PSGI->app($opt->dir, $opt->site)
34 );
35 }
36
37 1;
38