Skip to content

Commit

Permalink
added start_app method to Mojo::Command
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 24, 2012
1 parent 386f7b9 commit 7028e9b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@
This file documents the revision history for Perl extension Mojolicious.

2.67 2012-03-24
- Added start_app method to Mojo::Command.
- Improved documentation.
- Improved tests.

Expand Down
13 changes: 13 additions & 0 deletions lib/Mojo/Command.pm
Expand Up @@ -233,6 +233,12 @@ sub start {
ref $self ? $self->run(@args) : $self->new->run(@args);
}

sub start_app {
my $self = shift;
$ENV{MOJO_APP} = shift;
$self->start(@_);
}

sub write_file {
my ($self, $path, $data) = @_;

Expand Down Expand Up @@ -487,6 +493,13 @@ disabled with the C<MOJO_NO_DETECT> environment variable.
Start the command line interface.
=head2 C<start_app>
Mojo::Command->start_app('MyApp');
Mojo::Command->start_app(MyApp => @ARGV);
Start the command line interface for application.
=head2 C<write_file>
$command = $command->write_file('/foo/bar.txt', 'Hello World!');
Expand Down
7 changes: 2 additions & 5 deletions lib/Mojolicious/Command/generate/app.pm
Expand Up @@ -68,11 +68,8 @@ Please visit http://mojolicio.us for detailed installation instructions.
EOF
# Application
$ENV{MOJO_APP} ||= '<%= $class %>';
# Start commands
Mojolicious::Commands->start;
# Start commands for application
Mojolicious::Commands->start_app('<%= $class %>');
@@ appclass
% my $class = shift;
Expand Down
14 changes: 4 additions & 10 deletions lib/Mojolicious/Guides/Growing.pod
Expand Up @@ -555,11 +555,8 @@ allow running unit tests again.
use lib 'lib';
use Mojolicious::Commands;

# Application
$ENV{MOJO_APP} = 'MyApp';

# Start commands
Mojolicious::Commands->start;
# Start commands for application
Mojolicious::Commands->start_app('MyApp');

=head2 Controller class

Expand Down Expand Up @@ -672,11 +669,8 @@ environments.

EOF

# Application
$ENV{MOJO_APP} ||= 'MyApp';

# Start commands
Mojolicious::Commands->start;
# Start commands for application
Mojolicious::Commands->start_app('MyApp');

=head2 Simplified tests

Expand Down
7 changes: 2 additions & 5 deletions t/mojolicious/external/script/my_app
Expand Up @@ -24,8 +24,5 @@ Please visit http://mojolicio.us for detailed installation instructions.
EOF

# Application
$ENV{MOJO_APP} ||= 'MyApp';

# Start commands
Mojolicious::Commands->start;
# Start commands for application
Mojolicious::Commands->start_app('MyApp');

0 comments on commit 7028e9b

Please sign in to comment.