File Coverage

blib/lib/App/DuckPAN/Cmd/Env/Cmd/Set.pm
Criterion Covered Total %
statement 6 15 40.0
branch 0 4 0.0
condition 0 3 0.0
subroutine 2 3 66.6
pod 0 1 0.0
total 8 26 30.7


line stmt bran cond sub pod time code
1             package App::DuckPAN::Cmd::Env::Cmd::Set;
2             our $AUTHORITY = 'cpan:DDG';
3             # ABSTRACT: Sets the specified env variable value
4             $App::DuckPAN::Cmd::Env::Cmd::Set::VERSION = '1019';
5 1     1   917 use Moo;
  1         2  
  1         5  
6             with qw( App::DuckPAN::Cmd::Env::Cmd );
7              
8 1     1   273 use MooX::Options protect_argv => 0;
  1         5  
  1         5  
9              
10             sub run {
11 0     0 0   my ($self, $name, @params) = @_;
12 0 0 0       $self->env->help("<name> <value>") if !@params || !$name;
13 0           my $data = $self->env->load_env_ini;
14 0           $name = uc $name;
15 0           $data->{$name} = join(" ", @params);
16 0           eval { $self->env->save_env_ini($data) };
  0            
17 0 0         $self->root->emit_and_exit(1,"Please ensure that you are passing a valid value for the variable '". $name ."'!") if $@;
18 0           $self->root->emit_info("Successfully set '". $name ."=". $data->{$name} ."'!");
19             }
20              
21             1;
22              
23             __END__
24              
25             =pod
26              
27             =head1 NAME
28              
29             App::DuckPAN::Cmd::Env::Cmd::Set - Sets the specified env variable value
30              
31             =head1 VERSION
32              
33             version 1019
34              
35             =head1 AUTHOR
36              
37             DuckDuckGo <open@duckduckgo.com>, Zach Thompson <zach@duckduckgo.com>, Zaahir Moolla <moollaza@duckduckgo.com>, Torsten Raudssus <torsten@raudss.us> L<https://raudss.us/>
38              
39             =head1 COPYRIGHT AND LICENSE
40              
41             This software is Copyright (c) 2013 by DuckDuckGo, Inc. L<https://duckduckgo.com/>.
42              
43             This is free software, licensed under:
44              
45             The Apache License, Version 2.0, January 2004
46              
47             =cut