Maroš Kollár > MooseX-App-1.28 > MooseX::App::Plugin::Env

Download:
MooseX-App-1.28.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Source  

NAME ^

MooseX::App::Plugin::Env - Read options from environment

SYNOPSIS ^

In your base class:

 package MyApp;
 use MooseX::App qw(Env);

In your command class:

 package MyApp::SomeCommand;
 use MooseX::App::Command;
 
 option 'some_option' => (
     is         => 'rw',
     isa        => 'Str',
     cmd_env    => 'SOME_OPTION',
 );
 
 sub run {
     my ($self) = @_;
     say "Some option is ".$self->some_option;
 }

In your shell

 bash$ export SOME_OPTION=test
 bash$ myapp some_command
 Some option is test
 
 bash$ SOME_OPTION=test
 bash$ myapp some_command --some_option override
 Some option is override

DESCRIPTION ^

This plugin can read options from the shell environment. Just add 'cmd_env' and a name (all uppercase and no spaces) to the options you wish to read from the environment.

syntax highlighting: