Skip to content

Commit

Permalink
updated command reference with new commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 18, 2012
1 parent cf86f20 commit 27c7160
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,6 +1,6 @@
This file documents the revision history for Perl extension Mojolicious.

2.63 2012-03-17 00:00:00
2.63 2012-03-18 00:00:00
- Improved Mojolicious::Renderer performance.
- Improved documentation.
- Fixed bug that slowed down Mojolicious::Renderer.
Expand Down
35 changes: 12 additions & 23 deletions lib/Mojo/Command.pm
Expand Up @@ -171,23 +171,20 @@ sub run {
if ($name && $name =~ /^\w+$/ && ($name ne 'help' || $args[0])) {

# Help
my $help = $name eq 'help' ? 1 : 0;
my $help = $name eq 'help';
$name = shift @args if $help;
$help = 1 if $ENV{MOJO_HELP};

# Try all namespaces
my $module;
for my $namespace (@{$self->namespaces}) {
last if $module = _command("${namespace}::$name");
}
$module = _command("${_}::$name") and last for @{$self->namespaces};

# Command missing
die qq/Command "$name" missing, maybe you need to install it?\n/
unless $module;

# Run
my $command = $module->new;
return $help ? $command->help : $command->run(@args);
return $help ? $module->new->help : $module->new->run(@args);
}

# Test
Expand All @@ -199,10 +196,8 @@ sub run {
for my $namespace (@{$self->namespaces}) {
for my $module (@{Mojo::Loader->search($namespace)}) {
next unless my $command = _command($module);
$command =~ s/^$namespace\:://;
push @$commands, [$command => $module]
unless $seen->{$command};
$seen->{$command} = 1;
$command =~ s/^$namespace\:\://;
push @$commands, [$command => $module] unless $seen->{$command}++;
}
}

Expand All @@ -211,20 +206,17 @@ sub run {

# Make list
my $list = [];
my $len = 0;
my $max = 0;
foreach my $command (@$commands) {
my $name = $command->[0];
my $l = length $name;
$len = $l if $l > $len;
push @$list, [$name, $command->[1]->new->description];
my $len = length $command->[0];
$max = $len if $len > $max;
push @$list, [$command->[0], $command->[1]->new->description];
}

# Print list
foreach my $command (@$list) {
my $name = $command->[0];
my $description = $command->[1];
my $padding = ' ' x ($len - length $name);
print " $name$padding $description";
my ($name, $description) = @$command;
print " $name" . (' ' x ($max - length $name)) . " $description";
}
print $self->hint;
return 1;
Expand Down Expand Up @@ -267,14 +259,11 @@ sub write_rel_file {

sub _command {
my $module = shift;

if (my $e = Mojo::Loader->load($module)) {
return unless ref $e;
die $e;
}
return unless $module->isa('Mojo::Command');

return $module;
return $module->isa('Mojo::Command') ? $module : undef;
}

1;
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Command/cgi.pm
Expand Up @@ -37,7 +37,8 @@ Mojolicious::Command::cgi - CGI command
=head1 DESCRIPTION
L<Mojolicious::Command::cgi> is a command interface to L<Mojo::Server::CGI>.
L<Mojolicious::Command::cgi> starts applications with L<Mojo::Server::CGI>
backend.
=head1 ATTRIBUTES
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Command/cpanify.pm
Expand Up @@ -71,7 +71,7 @@ Mojolicious::Command::cpanify - Cpanify command
=head1 DESCRIPTION
L<Mojolicious::Command::cpanify> is a CPAN uploader.
L<Mojolicious::Command::cpanify> uploads files to CPAN.
=head1 ATTRIBUTES
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Command/daemon.pm
Expand Up @@ -68,8 +68,8 @@ Mojolicious::Command::daemon - Daemon command
=head1 DESCRIPTION
L<Mojolicious::Command::daemon> is a command interface to
L<Mojo::Server::Daemon>.
L<Mojolicious::Command::daemon> starts applications with
L<Mojo::Server::Daemon> backend.
=head1 ATTRIBUTES
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Command/generate/app.pm
Expand Up @@ -167,7 +167,8 @@ Mojolicious::Command::generate::app - App generator command
=head1 DESCRIPTION
L<Mojolicious::Command::generate::app> is an application generator.
L<Mojolicious::Command::generate::app> generates application directory
structures for fully functional L<Mojolicious> applications.
=head1 ATTRIBUTES
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Command/generate/lite_app.pm
Expand Up @@ -58,7 +58,8 @@ Mojolicious::Command::generate::lite_app - Lite app generator command
=head1 DESCRIPTION
L<Mojolicious::Command::generate::lite_app> is a application generator.
L<Mojolicious::Command::generate::lite_app> generate fully functional
L<Mojolicious::Lite> applications.
=head1 ATTRIBUTES
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Command/generate/makefile.pm
Expand Up @@ -38,7 +38,8 @@ Mojolicious::Command::generate::makefile - Makefile generator command
=head1 DESCRIPTION
L<Mojolicious::Command::generate::makefile> is a makefile generator.
L<Mojolicious::Command::generate::makefile> generates C<Makefile.PL> files
for applications.
=head1 ATTRIBUTES
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Command/generate/plugin.pm
Expand Up @@ -126,7 +126,8 @@ Mojolicious::Command::generate::plugin - Plugin generator command
=head1 DESCRIPTION
L<Mojolicious::Command::generate::plugin> is a plugin generator.
L<Mojolicious::Command::generate::plugin> generates directory structures for
fully functional L<Mojolicious> plugins.
=head1 ATTRIBUTES
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Command/get.pm
Expand Up @@ -223,8 +223,8 @@ L<Mojolicious::Command::get> is a command interface to L<Mojo::UserAgent>.
=head1 ATTRIBUTES
L<Mojolicious::Command::get> inherits all attributes from L<Mojo::Command>
and implements the following new ones.
L<Mojolicious::Command::get> performs requests to remote hosts or local
applications.
=head2 C<description>
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Command/inflate.pm
Expand Up @@ -41,8 +41,8 @@ Mojolicious::Command::inflate - Inflate command
=head1 DESCRIPTION
L<Mojolicious::Command::inflate> turns all your embedded templates into real
ones.
L<Mojolicious::Command::inflate> turns templates and static files embedded in
the C<DATA> sections of your application into real files.
=head1 ATTRIBUTES
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Command/psgi.pm
Expand Up @@ -26,8 +26,8 @@ Mojolicious::Command::psgi - PSGI command
=head1 DESCRIPTION
L<Mojolicious::Command::psgi> is a command interface to
L<Mojo::Server::PSGI>.
L<Mojolicious::Command::psgi> starts applications with L<Mojo::Server::PSGI>
backend.
=head1 ATTRIBUTES
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Command/routes.pm
Expand Up @@ -114,7 +114,7 @@ Mojolicious::Command::routes - Routes command
=head1 DESCRIPTION
L<Mojolicious::Command::routes> prints all your application routes.
L<Mojolicious::Command::routes> lists all your application routes.
=head1 ATTRIBUTES
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Command/test.pm
Expand Up @@ -67,7 +67,7 @@ Mojolicious::Command::test - Test command
=head1 DESCRIPTION
L<Mojolicious::Command::test> is a test script.
L<Mojolicious::Command::test> runs application tests from the C<t> directory.
=head1 ATTRIBUTES
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Command/version.pm
Expand Up @@ -77,7 +77,8 @@ Mojolicious::Command::version - Version command
=head1 DESCRIPTION
L<Mojolicious::Command::version> shows versions of installed modules.
L<Mojolicious::Command::version> shows version information for installed core
and optional modules.
=head1 ATTRIBUTES
Expand Down
26 changes: 23 additions & 3 deletions lib/Mojolicious/Commands.pm
Expand Up @@ -71,6 +71,12 @@ List available options for the command with short descriptions.
Start application with CGI backend.
=head2 C<cpanify>
$ mojo cpanify -u sri -p secr3t Mojolicious-2.0.tar.gz
Upload files to CPAN.
=head2 C<daemon>
$ mojo daemon
Expand Down Expand Up @@ -115,18 +121,32 @@ Generate a fully functional L<Mojolicious::Lite> application.
Generate C<Makefile.PL> file for application.
=head2 C<generate plugin>
$ mojo generate plugin <PluginName>
Generate directory structure for a fully functional L<Mojolicious> plugin.
=head2 C<get>
$ mojo get http://mojolicio.us
$ script/myapp get /foo
Perform GET request to remote host or local application.
Perform requests to remote host or local application.
=head2 C<inflate>
$ myapp.pl inflate
Turn embedded files from the C<DATA> section into real files.
Turn templates and static files embedded in the C<DATA> sections of your
application into real files.
=head2 C<psgi>
$ mojo psgi
$ script/myapp psgi
Start application with PSGI backend.
=head2 C<routes>
Expand All @@ -147,7 +167,7 @@ Runs application tests from the C<t> directory.
$ mojo version
List version information for installed core and optional modules, very useful
Show version information for installed core and optional modules, very useful
for debugging.
=head1 ATTRIBUTES
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -27,7 +27,7 @@ solid and fast enough for small to mid sized applications.
It has many configuration options and is known to work on every platform
Perl works on.

$ ./script/myapp help daemon
$ ./script/myapp daemon -h
...List of available options...

Another huge advantage is that it supports TLS and WebSockets out of the box.
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Types.pm
Expand Up @@ -88,8 +88,8 @@ List of MIME types.
=head1 METHODS
L<Mojolicious::Types> inherits all methods from L<Mojo::Base> and implements the
following ones.
L<Mojolicious::Types> inherits all methods from L<Mojo::Base> and implements
the following ones.
=head2 C<detect>
Expand Down

0 comments on commit 27c7160

Please sign in to comment.