Could anyone help explain the grammer about "has usage ...", "has description ..." in below cgi.pm?
package Mojolicious::Command::cgi;
use Mojo::Base 'Mojolicious::Command';
use Mojo::Server::CGI;
use Mojo::Util 'getopt';
has description => 'Start application with CGI';
has usage => sub { shift->extract_usage };
sub run {
my ($self, @args) = @_;
getopt \@args, nph => \(my $nph = 0);
Mojo::Server::CGI->new(app => $self->app, nph => $nph)->run;
}
1;
See the Mojo::Base documentation . The has
function defines an attribute for the class.
In this case Mojo::Command::cgi
has a Mojolicious::Command
base class and the description
attribute defaults to the string supplied, and the usage
attribute will be initialized by calling the extract_usage
method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.