Enbld/Command/Off.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 55 SCAR 17.9
CC
2
Cov
0%
do
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 6.0
1 package Enbld::Command::Off;
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::App::Configuration;
12 require Enbld::Error;
13 require Enbld::Exception;
14 require Enbld::Target;
15  
16 sub do {
17 my $self = shift;
18  
19 my $target_name = $self->validate_target_name( shift @{ $self->{argv} } );
20  
21 Enbld::Home->initialize;
22 Enbld::App::Configuration->read_file;
23  
24 my $config = Enbld::App::Configuration->search_config( $target_name );
25 my $target = Enbld::Target->new( $target_name, $config );
26  
27 my $offed = try {
28 return $target->off;
29 } ( 'Enbld::Error' => sub {
30 Enbld::Message->notify( $@ );
31 return;
32 }
33 );
34  
35 if ( $offed ) {
36 Enbld::App::Configuration->set_config( $offed );
37 }
38  
39 Enbld::App::Configuration->write_file;
40  
41 return $offed;
42 }
43  
44 1;