| 1 | package App::DuckPAN::Cmd::Env; | ||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:DDG'; | |||||||||
| 3 | # ABSTRACT: Env command class | ||||||||||
| 4 | 1 | $App::DuckPAN::Cmd::Env::VERSION = '1021'; | |||||||||
| 5 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use MooX::Cmd; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | with qw( App::DuckPAN::Cmd ); | |||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Config::INI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | has env_ini => ( | |||||||||
| 13 | is => 'ro', | ||||||||||
| 14 | lazy => 1, | ||||||||||
| 15 | builder => 1, | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub _build_env_ini { | ||||||||
|
Subroutine
_build_env_ini: not called CC=1 SCAR=6.9
| |||||||||||
| 19 | 0 | my ( $self ) = @_; | |||||||||
| 20 | 0 | $self->command_chain->[0]->root->cfg->config_path->child('env.ini') | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | sub load_env_ini { | ||||||||
|
Subroutine
load_env_ini: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 24 | 0 | my ( $self ) = @_; | |||||||||
| 25 | 0 | ▶ | if ($self->env_ini->is_file) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | my $data = Config::INI::Reader->read_file($self->env_ini)->{_}; | |||||||||
| 27 | 0 | ▶ | defined $data ? $data : {} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | } | ||||||||||
| 29 | else { | ||||||||||
| 30 | {} | ||||||||||
| 31 | 0 | } | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | sub save_env_ini { | ||||||||
|
Subroutine
save_env_ini: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 35 | 0 | my ( $self, $data ) = @_; | |||||||||
| 36 | 0 | Config::INI::Writer->write_file({ _ => $data }, $self->env_ini); | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 0 | ▶ | sub help { | ||||||||
|
Subroutine
help: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 40 | 0 | my ( $self, $cmd_input ) = @_; | |||||||||
| 41 | 0 | my $help_msg = "Available Commands:\n\t get: duckpan env get <name>\n\t help: duckpan env help\n\t ". | |||||||||
| 42 | "list: duckpan env list\n\t rm: duckpan env rm <name>\n\t set: duckpan env set <name> <value>"; | ||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | if($cmd_input) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 0 | ▶ | $self->command_chain->[0]->root->emit_and_exit(1, "Missing arguments!\n\t Usage:\tduckpan env ". $self->command_name ." ". $cmd_input) if $self->command_name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 0 | $self->app->emit_and_exit(1, "Command '". $cmd_input ."' not found\n". $help_msg); | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | $self->command_name ? $self->command_chain->[0]->root->emit_info($help_msg) : $self->app->emit_info($help_msg); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub run { | ||||||||
|
Subroutine
run: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 53 | 0 | my ( $self, $name ) = @_; | |||||||||
| 54 | 0 | ▶ | $self->help($name) if !$self->command_name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 0 | exit 0; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 1 | 1; | |||||||||
| 59 | |||||||||||
| 60 | __END__ | ||||||||||