add files
|
1 |
package Mojolicious::Command::cgi; |
2 |
use Mojo::Base 'Mojolicious::Command'; |
|
3 | ||
4 |
use Getopt::Long qw(GetOptionsFromArray :config no_auto_abbrev no_ignore_case); |
|
5 |
use Mojo::Server::CGI; |
|
6 | ||
7 |
has description => "Start application with CGI.\n"; |
|
8 |
has usage => <<EOF; |
|
9 |
usage: $0 cgi [OPTIONS] |
|
10 | ||
11 |
These options are available: |
|
12 |
--nph Enable non-parsed-header mode. |
|
13 |
EOF |
|
14 | ||
15 |
sub run { |
|
16 |
my ($self, @args) = @_; |
|
17 |
my $cgi = Mojo::Server::CGI->new(app => $self->app); |
|
18 |
GetOptionsFromArray \@args, nph => sub { $cgi->nph(1) }; |
|
19 |
$cgi->run; |
|
20 |
} |
|
21 | ||
22 |
1; |
|
23 | ||
24 |
=encoding utf8 |
|
25 | ||
26 |
=head1 NAME |
|
27 | ||
28 |
Mojolicious::Command::cgi - CGI command |
|
29 | ||
30 |
=head1 SYNOPSIS |
|
31 | ||
32 |
use Mojolicious::Command::CGI; |
|
33 | ||
34 |
my $cgi = Mojolicious::Command::CGI->new; |
|
35 |
$cgi->run(@ARGV); |
|
36 | ||
37 |
=head1 DESCRIPTION |
|
38 | ||
39 |
L<Mojolicious::Command::cgi> starts applications with L<Mojo::Server::CGI> |
|
40 |
backend. |
|
41 | ||
42 |
This is a core command, that means it is always enabled and its code a good |
|
43 |
example for learning to build new commands, you're welcome to fork it. |
|
44 | ||
45 |
=head1 ATTRIBUTES |
|
46 | ||
47 |
L<Mojolicious::Command::cgi> inherits all attributes from |
|
48 |
L<Mojolicious::Command> and implements the following new ones. |
|
49 | ||
50 |
=head2 description |
|
51 | ||
52 |
my $description = $cgi->description; |
|
53 |
$cgi = $cgi->description('Foo!'); |
|
54 | ||
55 |
Short description of this command, used for the command list. |
|
56 | ||
57 |
=head2 usage |
|
58 | ||
59 |
my $usage = $cgi->usage; |
|
60 |
$cgi = $cgi->usage('Foo!'); |
|
61 | ||
62 |
Usage information for this command, used for the help screen. |
|
63 | ||
64 |
=head1 METHODS |
|
65 | ||
66 |
L<Mojolicious::Command::cgi> inherits all methods from L<Mojolicious::Command> |
|
67 |
and implements the following new ones. |
|
68 | ||
69 |
=head2 run |
|
70 | ||
71 |
$cgi->run(@ARGV); |
|
72 | ||
73 |
Run this command. |
|
74 | ||
75 |
=head1 SEE ALSO |
|
76 | ||
77 |
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>. |
|
78 | ||
79 |
=cut |