Skip to content

Commit

Permalink
put more usage information in SYNOPSIS
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 29, 2014
1 parent 93165cf commit e3eec57
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 33 deletions.
14 changes: 1 addition & 13 deletions lib/Mojolicious/Command/generate.pm
Expand Up @@ -7,13 +7,8 @@ has hint => <<EOF;
See 'APPLICATION generate help GENERATOR' for more information on a specific
generator.
EOF
has message => <<EOF;
Usage: APPLICATION generate GENERATOR [OPTIONS]
Generators:
EOF
has message => sub { shift->extract_usage . "\nGenerators:\n" };
has namespaces => sub { ['Mojolicious::Command::generate'] };
has usage => sub { shift->extract_usage };

sub help { shift->run(@_) }

Expand Down Expand Up @@ -55,13 +50,6 @@ Short description of this command, used for the command list.
Short hint shown after listing available generator commands.
=head2 usage
my $usage = $generator->usage;
$generator = $generator->usage('Foo!');
Usage information for this command, used for the help screen.
=head2 message
my $msg = $generator->message;
Expand Down
30 changes: 11 additions & 19 deletions lib/Mojolicious/Commands.pm
Expand Up @@ -7,23 +7,9 @@ use Mojo::Server;

has hint => <<EOF;
Options (for all commands):
-h, --help Get more information on a specific command.
--home <path> Path to your applications home directory, defaults to
the value of MOJO_HOME or auto detection.
-m, --mode <name> Operating mode for your application, defaults to the
value of MOJO_MODE/PLACK_ENV or "development".
See 'APPLICATION help COMMAND' for more information on a specific command.
EOF
has message => <<EOF;
Usage: APPLICATION COMMAND [OPTIONS]
Tip: CGI and PSGI environments can be automatically detected very often and
work without commands.
Commands:
EOF
has message => sub { shift->extract_usage . "\nCommands:\n" };
has namespaces => sub { ['Mojolicious::Command'] };

sub detect {
Expand Down Expand Up @@ -125,11 +111,17 @@ Mojolicious::Commands - Command line interface
=head1 SYNOPSIS
use Mojolicious::Commands;
Usage: APPLICATION COMMAND [OPTIONS]
my $commands = Mojolicious::Commands->new;
push @{$commands->namespaces}, 'MyApp::Command';
$commands->run('daemon');
Tip: CGI and PSGI environments can be automatically detected very often and
work without commands.
Options (for all commands):
-h, --help Get more information on a specific command.
--home <path> Path to your applications home directory, defaults to
the value of MOJO_HOME or auto detection.
-m, --mode <name> Operating mode for your application, defaults to the
value of MOJO_MODE/PLACK_ENV or "development".
=head1 DESCRIPTION
Expand Down
8 changes: 7 additions & 1 deletion t/mojolicious/commands.t
Expand Up @@ -55,6 +55,11 @@ is $app->start('test_command'), 'works!', 'right result';
'works!', 'right result');
}

# mojo
ok $commands->description, 'has a description';
like $commands->message, qr/COMMAND/, 'has a message';
like $commands->hint, qr/help/, 'has a hint';

# cgi
require Mojolicious::Command::cgi;
my $cgi = Mojolicious::Command::cgi->new;
Expand Down Expand Up @@ -83,7 +88,8 @@ like $eval->usage, qr/eval/, 'has usage information';
require Mojolicious::Command::generate;
my $generator = Mojolicious::Command::generate->new;
ok $generator->description, 'has a description';
like $generator->usage, qr/generate/, 'has usage information';
like $generator->message, qr/generate/, 'has a message';
like $commands->hint, qr/help/, 'has a hint';

# generate app
require Mojolicious::Command::generate::app;
Expand Down

0 comments on commit e3eec57

Please sign in to comment.