Enbld/Command/Use.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 57 SCAR 24.8
CC
3
Cov
0%
do
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 12.0
1 package Enbld::Command::Use;
2  
3 use strict;
4 use warnings;
5  
6 use parent qw/Enbld::Command/;
7  
8 use Try::Lite;
9  
10 require Enbld::Home;
11 require Enbld::Error;
12 require Enbld::App::Configuration;
13 require Enbld::Target;
14  
15 sub do {
16 my $self = shift;
17  
18 my $target_name = $self->validate_target_name( shift @{ $self->{argv} } );
19 my $target_version = shift @{ $self->{argv} };
20  
21 if ( ! $target_version ) {
22 die( Enbld::Error->new( "'use' command requires version param." ) );
23 }
24  
25 Enbld::Home->initialize;
26 Enbld::App::Configuration->read_file;
27  
28 my $config = Enbld::App::Configuration->search_config( $target_name );
29 my $target = Enbld::Target->new( $target_name, $config );
30  
31 my $used = try {
32 return $target->use( $target_version );
33 } ( 'Enbld::Error' => sub {
34 Enbld::Message->alert( $@ );
35 return;
36 }
37 );
38  
39 if ( $used ) {
40 Enbld::App::Configuration->set_config( $used );
41 Enbld::App::Configuration->write_file;
42 }
43  
44 return $used;
45 }
46  
47 1;