your custom command will automatically use your app's config if it's run 
from the app script, e.g. 

> ./script/myapp dumpconfig -m production

you probably want to add this to your app startup so you can define 
app-specific custom commands by just dropping them in the Command dir
  push @{$self->commands->namespaces}, 'MyApp::Command';

and then put your custom commands in lib/MyApp/Command, for example

package MyApp::Command::dumpconfig;
use Mojo::Base 'Mojolicious::Command';

has description => 'dump mode-specific config to stdout';
# here's what you'll get from -h option
has usage       => "Usage: ./script/mojo dumpconfig [-m <mode>]\n";

sub run {
    my $self=shift;

    my $app = $self->app;
    say $app->dumper($app->config);;
}
1;



On Sunday, February 22, 2015 at 10:55:11 AM UTC-5, Luc didry wrote:
>
> Hello, 
>
> I got two questions with Mojolicious::Commands which are almost the same. 
>
> 1. Is there a way to share the config between a mojolicious app and a 
> custom command? I use the Config plugin in my application and I 
> successfully did the same in my custom command, but I have some default 
> values in my config, which I put when I add the plugin : 
>
> $self->plugin('Config', default => {foo => bar}); 
>
> Using the plugin twice means that I have to rewrite the default values 
> twice if I want to change them. 
>
> Is there something like $self->app->load_config_from_app or a plugin or 
> anything that can make me write things only one time ? 
>
> 2. I use the Minion plugin in my app. I want to use it in my command too. 
> Is there a way to use in my command the tasks I added in my app ? 
>
> By the way : Minion is really great and Mojo::Pg too! The migration tool 
> is soooooo useful! Thanks a lot :-) (and for Mojolicious too, of course :D) 
> -- 
> Luc 
> http://www.fiat-tux.fr/ 
> Internet n'est pas compliqué, Internet est ce que vous en faites. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to